| 510 | } |
| 511 | |
| 512 | unsigned int Seat::checkAllGoals() |
| 513 | { |
| 514 | // Loop over the goals vector and move any goals that have been met to the completed goals vector. |
| 515 | std::vector<Goal*> goalsToAdd; |
| 516 | std::vector<Goal*>::iterator currentGoal = mUncompleteGoals.begin(); |
| 517 | while (currentGoal != mUncompleteGoals.end()) |
| 518 | { |
| 519 | Goal* goal = *currentGoal; |
| 520 | // Start by checking if the goal has been met by this seat. |
| 521 | if (goal->isMet(*this, *mGameMap)) |
| 522 | { |
| 523 | mCompletedGoals.push_back(goal); |
| 524 | |
| 525 | // Add any subgoals upon completion to the list of outstanding goals. |
| 526 | for (unsigned int i = 0; i < goal->numSuccessSubGoals(); ++i) |
| 527 | goalsToAdd.push_back(goal->getSuccessSubGoal(i)); |
| 528 | |
| 529 | currentGoal = mUncompleteGoals.erase(currentGoal); |
| 530 | |
| 531 | mHasGoalsChanged = true; |
| 532 | |
| 533 | // Tells the player an objective has been met. |
| 534 | if((mGameMap->getTurnNumber() > 5) && |
| 535 | (getPlayer() != nullptr) && |
| 536 | getPlayer()->getIsHuman() && |
| 537 | !getPlayer()->getHasLost()) |
| 538 | { |
| 539 | ServerNotification *serverNotification = new ServerNotification( |
| 540 | ServerNotificationType::chatServer, getPlayer()); |
| 541 | |
| 542 | serverNotification->mPacket << "You have met an objective." << EventShortNoticeType::aboutObjectives; |
| 543 | ODServer::getSingleton().queueServerNotification(serverNotification); |
| 544 | |
| 545 | std::vector<Seat*> seats; |
| 546 | seats.push_back(this); |
| 547 | mGameMap->fireRelativeSound(seats, SoundRelativeKeeperStatements::GoalMet); |
| 548 | } |
| 549 | } |
| 550 | else |
| 551 | { |
| 552 | // If the goal has not been met, check to see if it cannot be met in the future. |
| 553 | if (goal->isFailed(*this, *mGameMap)) |
| 554 | { |
| 555 | mFailedGoals.push_back(goal); |
| 556 | |
| 557 | // Add any subgoals upon completion to the list of outstanding goals. |
| 558 | for (unsigned int i = 0; i < goal->numFailureSubGoals(); ++i) |
| 559 | goalsToAdd.push_back(goal->getFailureSubGoal(i)); |
| 560 | |
| 561 | currentGoal = mUncompleteGoals.erase(currentGoal); |
| 562 | mHasGoalsChanged = true; |
| 563 | |
| 564 | // Tells the player an objective has been failed. |
| 565 | if((mGameMap->getTurnNumber() > 5) && |
| 566 | (getPlayer() != nullptr) && |
| 567 | getPlayer()->getIsHuman() && |
| 568 | !getPlayer()->getHasLost()) |
| 569 | { |
no test coverage detected