* Update all our activity counters, gather all our scores, * get our countries to make sign pacts, adjust their fundings, * assess their satisfaction, and finally calculate our overall * total score, with thanks to Volutar for the formulas. */
| 288 | * total score, with thanks to Volutar for the formulas. |
| 289 | */ |
| 290 | void MonthlyReportState::calculateChanges() |
| 291 | { |
| 292 | // initialize all our variables. |
| 293 | _lastMonthsRating = 0; |
| 294 | int xcomSubTotal = 0; |
| 295 | int xcomTotal = 0; |
| 296 | int alienTotal = 0; |
| 297 | int monthOffset = _game->getSavedGame()->getFundsList().size() - 2; |
| 298 | int lastMonthOffset = _game->getSavedGame()->getFundsList().size() - 3; |
| 299 | if (lastMonthOffset < 0) |
| 300 | lastMonthOffset += 2; |
| 301 | |
| 302 | // update activity meters, calculate a total score based on regional activity |
| 303 | // and gather last month's score |
| 304 | for (std::vector<Region*>::iterator k = _game->getSavedGame()->getRegions()->begin(); k != _game->getSavedGame()->getRegions()->end(); ++k) |
| 305 | { |
| 306 | (*k)->newMonth(); |
| 307 | if ((*k)->getActivityXcom().size() > 2) |
| 308 | _lastMonthsRating += (*k)->getActivityXcom().at(lastMonthOffset)-(*k)->getActivityAlien().at(lastMonthOffset); |
| 309 | xcomSubTotal += (*k)->getActivityXcom().at(monthOffset); |
| 310 | alienTotal += (*k)->getActivityAlien().at(monthOffset); |
| 311 | } |
| 312 | |
| 313 | // apply research bonus AFTER calculating our total, because this bonus applies to the council ONLY, |
| 314 | // and shouldn't influence each country's decision. |
| 315 | |
| 316 | // the council is more lenient after the first month |
| 317 | if (_game->getSavedGame()->getMonthsPassed() > 1) |
| 318 | _game->getSavedGame()->getResearchScores().at(monthOffset) += 400; |
| 319 | |
| 320 | xcomTotal = _game->getSavedGame()->getResearchScores().at(monthOffset) + xcomSubTotal; |
| 321 | |
| 322 | |
| 323 | if (_game->getSavedGame()->getResearchScores().size() > 2) |
| 324 | _lastMonthsRating += _game->getSavedGame()->getResearchScores().at(lastMonthOffset); |
| 325 | |
| 326 | |
| 327 | // now that we have our totals we can send the relevant info to the countries |
| 328 | // and have them make their decisions weighted on the council's perspective. |
| 329 | for (std::vector<Country*>::iterator k = _game->getSavedGame()->getCountries()->begin(); k != _game->getSavedGame()->getCountries()->end(); ++k) |
| 330 | { |
| 331 | // add them to the list of new pact members |
| 332 | // this is done BEFORE initiating a new month |
| 333 | // because the _newPact flag will be reset in the |
| 334 | // process |
| 335 | if ((*k)->getNewPact()) |
| 336 | { |
| 337 | _pactList.push_back((*k)->getRules()->getType()); |
| 338 | } |
| 339 | |
| 340 | // determine satisfaction level, sign pacts, adjust funding |
| 341 | // and update activity meters, |
| 342 | (*k)->newMonth(xcomTotal, alienTotal); |
| 343 | |
| 344 | // and after they've made their decisions, calculate the difference, and add |
| 345 | // them to the appropriate lists. |
| 346 | _fundingDiff += (*k)->getFunding().back()-(*k)->getFunding().at((*k)->getFunding().size()-2); |
| 347 | switch((*k)->getSatisfaction()) |
nothing calls this directly
no test coverage detected