MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / newMonth

Method newMonth

src/Savegame/Country.cpp:165–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163 */
164
165void Country::newMonth(int xcomTotal, int alienTotal)
166{
167 _satisfaction = 2;
168 int funding = getFunding().back();
169 int good = (xcomTotal / 10) + _activityXcom.back();
170 int bad = (alienTotal / 20) + _activityAlien.back();
171 int oldFunding = _funding.back() / 1000;
172 int newFunding = (oldFunding * RNG::generate(5, 20) / 100) * 1000;
173
174 if (bad <= good + 30)
175 {
176 if (good > bad + 30)
177 {
178 if (RNG::generate(0, good) > bad)
179 {
180 // don't go over the cap
181 int cap = getRules()->getFundingCap()*1000;
182 if (funding + newFunding > cap)
183 newFunding = cap - funding;
184 if (newFunding)
185 _satisfaction = 3;
186 }
187 }
188 }
189 else
190 {
191 if (RNG::generate(0, bad) > good)
192 {
193 if (newFunding)
194 {
195 newFunding = -newFunding;
196 _satisfaction = 1;
197 }
198 }
199 }
200
201 // about to be in cahoots
202 if(_newPact && !_pact)
203 {
204 _newPact = false;
205 _pact = true;
206 addActivityAlien(150);
207 }
208
209
210
211 // set the new funding and reset the activity meters
212 if(_pact)
213 _funding.push_back(0);
214 else if (_satisfaction != 2)
215 _funding.push_back(funding + newFunding);
216 else
217 _funding.push_back(funding);
218
219 _activityAlien.push_back(0);
220 _activityXcom.push_back(0);
221 if(_activityAlien.size() > 12)
222 _activityAlien.erase(_activityAlien.begin());

Callers

nothing calls this directly

Calls 2

generateFunction · 0.85
getFundingCapMethod · 0.80

Tested by

no test coverage detected