Make Powerup Love use a generic counter

This commit is contained in:
Alayan 2018-10-02 12:36:20 +02:00 committed by auriamg
parent 69ee99c495
commit a32834e518
3 changed files with 18 additions and 4 deletions

View File

@ -218,6 +218,14 @@ void AchievementsStatus::updateAchievementsProgress(unsigned int achieve_data_id
gold_driver->increase("std_timetrial", "std_timetrial", m_variables[ACHIEVE_WON_TT_RACES].counter);
gold_driver->increase("follow_leader", "follow_leader", m_variables[ACHIEVE_WON_FTL_RACES].counter);
}
Achievement *powerup_lover = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_POWERUP_LOVER);
if (!powerup_lover->isAchieved())
{
powerup_lover->reset();
powerup_lover->increase("poweruplover", "poweruplover", m_variables[ACHIEVE_POWERUP_USED_1RACE].counter);
}
}
// ----------------------------------------------------------------------------
@ -256,13 +264,15 @@ void AchievementsStatus::resetDataVar(unsigned int achieve_data_id)
} // resetDataVar
// ----------------------------------------------------------------------------
void AchievementsStatus::onRaceEnd()
void AchievementsStatus::onRaceEnd(bool aborted)
{
//reset all values that need to be reset
std::map<uint32_t, Achievement *>::iterator iter;
for ( iter = m_achievements.begin(); iter != m_achievements.end(); ++iter ) {
iter->second->onRaceEnd();
}
m_variables[ACHIEVE_POWERUP_USED_1RACE].counter = 0;
} // onRaceEnd
// ----------------------------------------------------------------------------

View File

@ -53,8 +53,11 @@ public :
ACHIEVE_CONS_WON_RACES = 4,
// Won races in (at least) hard requires at least 5 AI opponents
ACHIEVE_CONS_WON_RACES_HARD = 5,
// Count the number of powerups used by the player.
ACHIEVE_POWERUP_USED = 6,
ACHIEVE_POWERUP_USED_1RACE = 7,
ACHIEVE_DATA_NUM = 6
ACHIEVE_DATA_NUM = 8
};
private:
@ -96,7 +99,7 @@ public :
void updateAchievementsProgress(unsigned int achieve_data_id);
void increaseDataVar(unsigned int achieve_data_id, int increase);
void resetDataVar(unsigned int achieve_data_id);
void onRaceEnd();
void onRaceEnd(bool aborted=false);
void onLapEnd();
// ------------------------------------------------------------------------
const std::map<uint32_t, Achievement *>& getAllAchievements()

View File

@ -254,7 +254,8 @@ void Powerup::use()
if (m_type != PowerupManager::POWERUP_NOTHING &&
m_kart->getController()->canGetAchievements() )
{
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_POWERUP_LOVER, "poweruplover");
PlayerManager::increaseAchievement(AchievementsStatus::ACHIEVE_POWERUP_USED, 1);
PlayerManager::increaseAchievement(AchievementsStatus::ACHIEVE_POWERUP_USED_1RACE, 1);
}
// Play custom kart sound when collectible is used //TODO: what about the bubble gum?