| 1262 | } |
| 1263 | |
| 1264 | void GameState::weeklyPlayerUpdate() |
| 1265 | { |
| 1266 | // Player government income |
| 1267 | if (!fundingTerminated) |
| 1268 | { |
| 1269 | if (government->isRelatedTo(player) == Organisation::Relation::Hostile || |
| 1270 | totalScore.getTotal() < -2400) |
| 1271 | { |
| 1272 | fundingTerminated = true; |
| 1273 | player->income = 0; |
| 1274 | } |
| 1275 | else |
| 1276 | { |
| 1277 | int income = player->income; |
| 1278 | |
| 1279 | // Reduce this week's income if government doesn't have enough funds |
| 1280 | const int availableGovFunds = government->balance / 2; |
| 1281 | if (availableGovFunds < income) |
| 1282 | { |
| 1283 | income = (availableGovFunds < 0) ? 0 : availableGovFunds; |
| 1284 | } |
| 1285 | |
| 1286 | // Actual money transfer |
| 1287 | player->balance += income; |
| 1288 | government->balance -= income; |
| 1289 | |
| 1290 | const int fundingModifier = calculateFundingModifier(); |
| 1291 | if (fundingModifier != 0) |
| 1292 | { |
| 1293 | player->income += player->income / fundingModifier; |
| 1294 | } |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | // Player overheads: salary and base upkeep |
| 1299 | int totalSalary = 0; |
| 1300 | for (const auto &a : agents) |
| 1301 | { |
| 1302 | if (a.second->owner == player) |
| 1303 | { |
| 1304 | auto it = agent_salary.find(a.second->type->role); |
| 1305 | if (it != agent_salary.end()) |
| 1306 | { |
| 1307 | totalSalary += it->second; |
| 1308 | } |
| 1309 | } |
| 1310 | } |
| 1311 | |
| 1312 | int basesCosts = 0; |
| 1313 | for (const auto &b : player_bases) |
| 1314 | { |
| 1315 | for (const auto &f : b.second->facilities) |
| 1316 | { |
| 1317 | basesCosts += f->type->weeklyCost; |
| 1318 | } |
| 1319 | } |
| 1320 | player->balance = player->balance - totalSalary - basesCosts; |
| 1321 |
nothing calls this directly
no test coverage detected