Block the final challenge being accessed earlier than intended

This commit is contained in:
Alayan 2018-10-07 19:12:13 +02:00
parent ff7b94652a
commit 0766df61f2
7 changed files with 33 additions and 4 deletions

View File

@ -3,7 +3,7 @@
<unlock_list list="false"/>
<track id="fortmagma" laps="3" reverse="false"/>
<mode major="single" minor="quickrace"/>
<requirements trophies="190"/>
<requirements trophies="190" challenges="25"/>
<best>
<karts number="2" aiIdent="nolok" superPower="nolokBoss"/>

View File

@ -44,6 +44,7 @@ ChallengeData::ChallengeData(const std::string& filename)
m_gp_id = "";
m_version = 0;
m_num_trophies = 0;
m_num_completed_challenges = 0;
m_is_unlock_list = false;
m_is_ghost_replay = false;
@ -120,6 +121,8 @@ ChallengeData::ChallengeData(const std::string& filename)
}
requirements_node->get("trophies", &m_num_trophies);
requirements_node->get("challenges", &m_num_completed_challenges);
//Don't check further if this is an unlock list
if(m_is_unlock_list)
return;

View File

@ -122,6 +122,9 @@ private:
/** Number of trophies required to access this challenge */
int m_num_trophies;
/** Number of completed challenges required to access this challenge
* (esp. useful for the final challenge) */
int m_num_completed_challenges;
public:
ChallengeData(const std::string& filename);
@ -192,6 +195,9 @@ public:
/** Get number of required trophies to start this challenge */
int getNumTrophies() const { return m_num_trophies; }
// ------------------------------------------------------------------------
/** Get number of required completed challenges to start this challenge */
int getNumChallenges() const { return m_num_completed_challenges; }
// ------------------------------------------------------------------------
/** Returns if this challenge is a grand prix. */
bool isGrandPrix() const { return m_mode == CM_GRAND_PRIX; }
// ------------------------------------------------------------------------

View File

@ -99,6 +99,10 @@ public:
/** Clear the list of recently unlocked challenges */
void clearUnlocked () {m_unlocked_features.clear(); }
// ------------------------------------------------------------------------
/** Returns the number of completed challenges. */
int getNumCompletedChallenges () const { return (m_easy_challenges + m_medium_challenges +
m_hard_challenges + m_best_challenges); }
// ------------------------------------------------------------------------
/** Returns the number of points accumulated. */
int getPoints () const { return m_points; }
// ------------------------------------------------------------------------

View File

@ -228,6 +228,8 @@ public:
* fulfilled). */
void grandPrixFinished() { m_story_mode_status->grandPrixFinished(); }
// ------------------------------------------------------------------------
unsigned int getNumCompletedChallenges() const { return m_story_mode_status->getNumCompletedChallenges(); }
// ------------------------------------------------------------------------
unsigned int getPoints() const { return m_story_mode_status->getPoints(); }
// ------------------------------------------------------------------------
unsigned int getPointsBefore() const { return m_story_mode_status->getPointsBefore(); }

View File

@ -255,7 +255,14 @@ void OverWorld::onFirePressed(Controller* who)
}
const unsigned int val = challenge->getNumTrophies();
bool unlocked = (PlayerManager::getCurrentPlayer()->getPoints() >= val);
// Android may have less challenges available than the main version
#ifdef ANDROID
bool enough_challenges = true;
#else
const unsigned int val2 = challenge->getNumChallenges();
bool enough_challenges = (PlayerManager::getCurrentPlayer()->getNumCompletedChallenges() >= val2);
#endif
bool unlocked = enough_challenges && (PlayerManager::getCurrentPlayer()->getPoints() >= val);
if (UserConfigParams::m_everything_unlocked)
unlocked = true;

View File

@ -100,8 +100,15 @@ namespace Scripting
}
const unsigned int val = challenge->getNumTrophies();
bool shown = (PlayerManager::getCurrentPlayer()->getPoints() >= val);
return shown;
// Android may have less challenges available than the main version
#ifdef ANDROID
bool enough_challenges = true;
#else
const unsigned int val2 = challenge->getNumChallenges();
bool enough_challenges = (PlayerManager::getCurrentPlayer()->getNumCompletedChallenges() >= val2);
#endif
bool unlocked = enough_challenges && (PlayerManager::getCurrentPlayer()->getPoints() >= val);
return unlocked;
} // isChallengeUnlocked
// --------------------------------------------------------------------