-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathItem_Attributes.cpp
84 lines (67 loc) · 1.27 KB
/
Item_Attributes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#pragma once
#ifndef WORLDSIM_ITEM_ATTRIBUTES_CPP
#define WORLDSIM_ITEM_ATTRIBUTES_CPP
/* Item_Attributes.cpp
#include"Item_Attributes.cpp"
Container for attributes of an item. Includes tools for comparing with other items.
*/
#include "Item_Attributes.hpp"
#include "Job.hpp"
Item_Attributes::Item_Attributes()
{
durability=5;
health=5;
woodcuttingValue=0;
farmingValue=0;
miningValue=0;
}
// Item must meet all minimum requirements
int Item_Attributes::suitability(Job* job)
{
if (!job) return -1; // Return -1 if the job is null
int score = 0;
if ( job->desiredWoodcuttingValue > 0 )
{
if ( woodcuttingValue < job->desiredWoodcuttingValue )
{
return -1;
}
else
{
score+=woodcuttingValue-job->desiredWoodcuttingValue;
}
}
if ( job->desiredFarmingValue > 0 )
{
if ( farmingValue < job->desiredFarmingValue )
{
return -1;
}
else
{
score+=farmingValue-job->desiredFarmingValue;
}
}
if ( job->desiredMiningValue > 0 )
{
if ( miningValue < job->desiredMiningValue )
{
return -1;
}
else
{
score+=miningValue-job->desiredMiningValue;
}
}
return score;
}
bool Item_Attributes::degrade( int amount )
{
health-=amount;
if ( health <= 0 )
{
return true;
}
return false;
}
#endif // WORLDSIM_ITEM_ATTRIBUTES_CPP