Split off from updateDailyPlayer
| 174 | |
| 175 | // Split off from updateDailyPlayer |
| 176 | void Company::evaluateChallengeProgress() |
| 177 | { |
| 178 | if (challengeProgress == 100) |
| 179 | { |
| 180 | challengeFlags |= CompanyFlags::challengeCompleted; |
| 181 | if (CompanyManager::getControllingId() == id()) |
| 182 | { |
| 183 | if (CompanyManager::getSecondaryPlayerId() != CompanyId::null) |
| 184 | { |
| 185 | auto* secondaryPlayer = CompanyManager::get(CompanyManager::getSecondaryPlayerId()); |
| 186 | secondaryPlayer->challengeFlags |= CompanyFlags::challengeBeatenByOpponent; |
| 187 | Ui::WindowManager::invalidate(Ui::WindowType::company, enumValue(secondaryPlayer->id())); |
| 188 | } |
| 189 | MessageManager::post(MessageType::congratulationsCompleted, id(), enumValue(id()), 0xFFFF); |
| 190 | companyEmotionEvent(id(), Emotion::happy); |
| 191 | updateOwnerEmotion(); |
| 192 | Ui::Windows::CompanyWindow::openChallenge(id()); |
| 193 | Scenario::getObjectiveProgress().completedChallengeInMonths = Scenario::getObjectiveProgress().monthsInChallenge; |
| 194 | ScenarioManager::saveNewScore(Scenario::getObjectiveProgress(), id()); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | if (CompanyManager::getControllingId() != CompanyId::null) |
| 199 | { |
| 200 | auto* secondaryPlayer = CompanyManager::get(CompanyManager::getControllingId()); |
| 201 | secondaryPlayer->challengeFlags |= CompanyFlags::challengeBeatenByOpponent; |
| 202 | Ui::WindowManager::invalidate(Ui::WindowType::company, enumValue(secondaryPlayer->id())); |
| 203 | } |
| 204 | MessageManager::post(MessageType::haveBeenBeaten, id(), enumValue(id()), 0xFFFF); |
| 205 | companyEmotionEvent(id(), Emotion::surprised); |
| 206 | updateOwnerEmotion(); |
| 207 | Ui::Windows::CompanyWindow::openChallenge(id()); |
| 208 | Scenario::getObjectiveProgress().completedChallengeInMonths = Scenario::getObjectiveProgress().monthsInChallenge; |
| 209 | } |
| 210 | } |
| 211 | else if (challengeProgress == 255) |
| 212 | { |
| 213 | challengeFlags |= CompanyFlags::challengeFailed; |
| 214 | if (CompanyManager::getControllingId() == id()) |
| 215 | { |
| 216 | MessageManager::post(MessageType::failedObjectives, id(), enumValue(id()), 0xFFFF); |
| 217 | companyEmotionEvent(id(), Emotion::dejected); |
| 218 | updateOwnerEmotion(); |
| 219 | Ui::Windows::CompanyWindow::openChallenge(id()); |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // Converts performance index to rating |
| 225 | // 0x00437D60 |
no test coverage detected