-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJob.cpp
145 lines (120 loc) · 2.25 KB
/
Job.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#pragma once
#ifndef WORLDSIM_JOB_CPP
#define WORLDSIM_JOB_CPP
/* WorldSim: Job
#include "Job.cpp"
Manage jobs which need to be done.
*/
#include "Job.hpp"
Job::Job()
{
type = JOB_UNKNOWN;
requiredAction = ITEM_ACTION_NONE; // This should become a function
requiredLocation = LOCATION_NONE;
desiredWoodcuttingValue = 0;
desiredFarmingValue = 0;
desiredMiningValue = 0;
}
Job::~Job()
{
}
bool Job::canDoJob()
{
return true;
}
int Job::jobValue()
{
return 0;
}
Item* Job::getBestItem(Vector<Item*>* vItem)
{
Item* bestItem = nullptr;
int bestScore = -1;
for (int i = 0; i < vItem->size(); ++i)
{
const int score = vItem->at(i)->attributes.suitability(this);
if (score > bestScore)
{
bestScore = score;
bestItem = vItem->at(i);
}
}
return bestItem;
}
Item* Job::getBestItem(Item* item1, Item* item2)
{
if ( item1 == 0 )
{
return item2;
}
if ( item2 == 0 )
{
return item1;
}
const int score1 = item1->attributes.suitability(this);
const int score2 = item2->attributes.suitability(this);
if (score1 >= score2)
{
return item1;
}
return item2;
}
std::string Job::getName()
{
return "unknown";
}
Job_Woodcutting::Job_Woodcutting() : Job()
{
type = JOB_WOODCUTTING;
requiredLocation = LOCATION_WILDERNESS;
requiredAction = ITEM_ACTION_WOODCUTTING;
desiredWoodcuttingValue = 1;
}
std::string Job_Woodcutting::getName()
{
return "woodcutting";
}
Job_Mining::Job_Mining() : Job()
{
type = JOB_MINING;
requiredLocation = LOCATION_MINE;
requiredAction = ITEM_ACTION_MINING;
desiredMiningValue = 1;
}
std::string Job_Mining::getName()
{
return "mining";
}
Job_Hunting::Job_Hunting() : Job()
{
type = JOB_HUNTING;
requiredLocation = LOCATION_WILDERNESS;
requiredAction = ITEM_ACTION_HUNTING_RANGED;
desiredMiningValue = 1;
}
std::string Job_Hunting::getName()
{
return "hunting";
}
Job_Farming::Job_Farming() : Job()
{
type = JOB_FARMING;
requiredLocation = LOCATION_FARM;
requiredAction = ITEM_ACTION_FARMING;
desiredFarmingValue = 1;
}
std::string Job_Farming::getName()
{
return "farming";
}
Job_Prospecting::Job_Prospecting() : Job()
{
type = JOB_PROSPECTING;
requiredAction = ITEM_ACTION_MINING;
desiredMiningValue = 1;
}
std::string Job_Prospecting::getName()
{
return "prospecting";
}
#endif // WORLDSIM_JOB_CPP