MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / checkAllGoals

Method checkAllGoals

source/game/Seat.cpp:512–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510}
511
512unsigned 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 {

Callers 1

doMiscUpkeepMethod · 0.80

Calls 11

numSuccessSubGoalsMethod · 0.80
getSuccessSubGoalMethod · 0.80
getTurnNumberMethod · 0.80
getIsHumanMethod · 0.80
getHasLostMethod · 0.80
fireRelativeSoundMethod · 0.80
numFailureSubGoalsMethod · 0.80
getFailureSubGoalMethod · 0.80
isMetMethod · 0.45
isFailedMethod · 0.45

Tested by

no test coverage detected