/** This is called when a GP is finished. See if there is an active * challenge that was fulfilled. */ void StoryModeStatus::grandPrixFinished() { if(m_current_challenge && m_current_challenge->isActive(race_manager->getDifficulty()) && m_current_challenge->getData()->isGPFulfilled() ) { unlockFeature(const_cast<ChallengeStatus*>(m_current_challenge), race_manager->getDifficulty()); } // if isActive && challenge solved race_manager->setCoinTarget(0); } // grandPrixFinished
/** This is called when a race is finished. See if there is an active * challenge that was fulfilled. */ void StoryModeStatus::raceFinished() { if(m_current_challenge && m_current_challenge->isActive(race_manager->getDifficulty()) && m_current_challenge->getData()->isChallengeFulfilled() ) { // cast const away so that the challenge can be set to fulfilled. // The 'clean' implementation would involve searching the challenge // in m_challenges_state, which is a bit of an overkill unlockFeature(const_cast<ChallengeStatus*>(m_current_challenge), race_manager->getDifficulty()); } // if isActive && challenge solved } // raceFinished
void GameSlot::grandPrixFinished() { std::map<std::string, Challenge*>::const_iterator i; for(i = m_challenges_state.begin(); i != m_challenges_state.end(); i++) { if(i->second->isActive(race_manager->getDifficulty()) && i->second->getData()->grandPrixFinished()) { printf("===== A FEATURE WAS UNLOCKED BECAUSE YOU WON THE GP!! ==\n"); unlockFeature(i->second, race_manager->getDifficulty()); } } race_manager->setCoinTarget(0); } // grandPrixFinished
/** This is called when a race is finished. Call all active challenges */ void GameSlot::raceFinished() { printf("=== Race finished ===\n"); std::map<std::string, Challenge*>::const_iterator i; for(i = m_challenges_state.begin(); i != m_challenges_state.end(); i++) { if(i->second->isActive(race_manager->getDifficulty()) && i->second->getData()->raceFinished()) { unlockFeature(i->second, race_manager->getDifficulty()); } // if isActive && challenge solved } //race_manager->setCoinTarget(0); //reset } // raceFinished
//----------------------------------------------------------------------------- void GameSlot::computeActive() { m_points = 0; m_easy_challenges = 0; m_medium_challenges = 0; m_hard_challenges = 0; m_locked_features.clear(); // start afresh std::map<std::string, Challenge*>::const_iterator i; for(i = m_challenges_state.begin(); i != m_challenges_state.end(); i++) { // Changed challenge // ----------------- if((i->second)->isSolvedAtAnyDifficulty()) { // The constructor calls computeActive, which actually locks // all features, so unlock the solved ones (and don't try to // save the state, since we are currently reading it) if (i->second->isSolved(RaceManager::DIFFICULTY_EASY)) { unlockFeature(i->second, RaceManager::DIFFICULTY_EASY, /*save*/ false); } if (i->second->isSolved(RaceManager::DIFFICULTY_MEDIUM)) { unlockFeature(i->second, RaceManager::DIFFICULTY_MEDIUM, /*save*/ false); } if (i->second->isSolved(RaceManager::DIFFICULTY_HARD)) { unlockFeature(i->second, RaceManager::DIFFICULTY_HARD, /*save*/ false); } if (i->second->isSolved(RaceManager::DIFFICULTY_HARD)) { m_points += CHALLENGE_POINTS[RaceManager::DIFFICULTY_HARD]; m_hard_challenges++; } else if (i->second->isSolved(RaceManager::DIFFICULTY_MEDIUM)) { m_points += CHALLENGE_POINTS[RaceManager::DIFFICULTY_MEDIUM]; m_medium_challenges++; } else if (i->second->isSolved(RaceManager::DIFFICULTY_EASY)) { m_points += CHALLENGE_POINTS[RaceManager::DIFFICULTY_EASY]; m_easy_challenges++; } } else { // Otherwise lock the feature // -------------------------- lockFeature(i->second); } if (i->second->isSolved(RaceManager::DIFFICULTY_HARD)) { // challenge beaten at hardest, nothing more to do here continue; } else if (i->second->isSolved(RaceManager::DIFFICULTY_MEDIUM)) { i->second->setActive(RaceManager::DIFFICULTY_HARD); } else if (i->second->isSolved(RaceManager::DIFFICULTY_EASY)) { i->second->setActive(RaceManager::DIFFICULTY_HARD); i->second->setActive(RaceManager::DIFFICULTY_MEDIUM); } else { i->second->setActive(RaceManager::DIFFICULTY_HARD); i->second->setActive(RaceManager::DIFFICULTY_MEDIUM); i->second->setActive(RaceManager::DIFFICULTY_EASY); } } // for i // now we have the number of points. Actually lock the tracks for (i = m_challenges_state.begin(); i != m_challenges_state.end(); i++) { if (m_points < i->second->getData()->getNumTrophies()) { if (i->second->getData()->getTrackId().size() > 0) m_locked_features[i->second->getData()->getTrackId()] = true; else if (i->second->getData()->getGPId().size() > 0) m_locked_features[i->second->getData()->getGPId()] = true; } } clearUnlocked(); } // computeActive