forked from miki151/keeperrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collective_config.cpp
189 lines (151 loc) · 4.71 KB
/
collective_config.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include "stdafx.h"
#include "util.h"
#include "creature.h"
#include "collective_config.h"
#include "tribe.h"
AttractionInfo::AttractionInfo(MinionAttraction a, double cl, double min, bool mand)
: attraction(a), amountClaimed(cl), minAmount(min), mandatory(mand) {}
template <class Archive>
void CollectiveConfig::serialize(Archive& ar, const unsigned int version) {
ar& SVAR(immigrantFrequency)
& SVAR(payoutTime)
& SVAR(payoutMultiplier)
& SVAR(maxPopulation)
& SVAR(populationIncreases)
& SVAR(immigrantInfo)
& SVAR(type)
& SVAR(recruitingMinPopulation)
& SVAR(leaderAsFighter)
& SVAR(spawnGhosts)
& SVAR(ghostProb)
& SVAR(guardianInfo);
}
SERIALIZABLE(CollectiveConfig);
SERIALIZATION_CONSTRUCTOR_IMPL(CollectiveConfig);
template <class Archive>
void ImmigrantInfo::serialize(Archive& ar, const unsigned int version) {
ar& SVAR(id)
& SVAR(frequency)
& SVAR(attractions)
& SVAR(traits)
& SVAR(spawnAtDorm)
& SVAR(salary)
& SVAR(techId)
& SVAR(limit)
& SVAR(groupSize)
& SVAR(autoTeam)
& SVAR(ignoreSpawnType);
}
SERIALIZABLE(ImmigrantInfo);
template <class Archive>
void AttractionInfo::serialize(Archive& ar, const unsigned int version) {
ar& SVAR(attraction)
& SVAR(amountClaimed)
& SVAR(minAmount)
& SVAR(mandatory);
}
SERIALIZABLE(AttractionInfo);
SERIALIZATION_CONSTRUCTOR_IMPL(AttractionInfo);
template <class Archive>
void PopulationIncrease::serialize(Archive& ar, const unsigned int version) {
ar& SVAR(type)
& SVAR(increasePerSquare)
& SVAR(maxIncrease);
}
SERIALIZABLE(PopulationIncrease);
template <class Archive>
void GuardianInfo::serialize(Archive& ar, const unsigned int version) {
ar& SVAR(creature)
& SVAR(probability)
& SVAR(minEnemies)
& SVAR(minVictims);
}
SERIALIZABLE(GuardianInfo);
CollectiveConfig::CollectiveConfig(double freq, int payoutT, double payoutM, vector<ImmigrantInfo> im,
CollectiveType t, int maxPop, vector<PopulationIncrease> popInc)
: immigrantFrequency(freq), payoutTime(payoutT), payoutMultiplier(payoutM),
maxPopulation(maxPop), populationIncreases(popInc), immigrantInfo(im), type(t) {}
CollectiveConfig CollectiveConfig::keeper(double freq, int payout, double payoutMult, int maxPopulation,
vector<PopulationIncrease> increases, vector<ImmigrantInfo> im) {
return CollectiveConfig(freq, payout, payoutMult, im, KEEPER, maxPopulation, increases);
}
CollectiveConfig CollectiveConfig::withImmigrants(double frequency, int maxPopulation, vector<ImmigrantInfo> im) {
return CollectiveConfig(frequency, 0, 0, im, VILLAGE, maxPopulation, {});
}
CollectiveConfig CollectiveConfig::noImmigrants() {
return CollectiveConfig(0, 0, 0, {}, VILLAGE, 10000, {});
}
CollectiveConfig& CollectiveConfig::setLeaderAsFighter() {
leaderAsFighter = true;
return *this;
}
CollectiveConfig& CollectiveConfig::setGhostSpawns(double prob, int num) {
ghostProb = prob;
spawnGhosts = num;
return *this;
}
int CollectiveConfig::getNumGhostSpawns() const {
return spawnGhosts;
}
double CollectiveConfig::getGhostProb() const {
return ghostProb;
}
bool CollectiveConfig::isLeaderFighter() const {
return leaderAsFighter;
}
bool CollectiveConfig::getManageEquipment() const {
return type == KEEPER;
}
bool CollectiveConfig::getWorkerFollowLeader() const {
return type == KEEPER;
}
bool CollectiveConfig::sleepOnlyAtNight() const {
return type != KEEPER;
}
double CollectiveConfig::getImmigrantFrequency() const {
return immigrantFrequency;
}
int CollectiveConfig::getPayoutTime() const {
return payoutTime;
}
double CollectiveConfig::getPayoutMultiplier() const {
return payoutMultiplier;
}
bool CollectiveConfig::getStripSpawns() const {
return type == KEEPER;
}
bool CollectiveConfig::getFetchItems() const {
return type == KEEPER;
}
bool CollectiveConfig::getEnemyPositions() const {
return type == KEEPER;
}
bool CollectiveConfig::getWarnings() const {
return type == KEEPER;
}
bool CollectiveConfig::getConstructions() const {
return type == KEEPER;
}
int CollectiveConfig::getMaxPopulation() const {
return maxPopulation;
}
optional<int> CollectiveConfig::getRecruitingMinPopulation() const {
return recruitingMinPopulation;
}
CollectiveConfig& CollectiveConfig::allowRecruiting(int minPop) {
recruitingMinPopulation = minPop;
return *this;
}
const vector<ImmigrantInfo>& CollectiveConfig::getImmigrantInfo() const {
return immigrantInfo;
}
const vector<PopulationIncrease>& CollectiveConfig::getPopulationIncreases() const {
return populationIncreases;
}
CollectiveConfig& CollectiveConfig::setGuardian(GuardianInfo info) {
guardianInfo = info;
return *this;
}
const optional<GuardianInfo>& CollectiveConfig::getGuardianInfo() const {
return guardianInfo;
}