From bdbd66dbb7b8aeb6e73606ab9b528f91af57866d Mon Sep 17 00:00:00 2001 From: Alayan Date: Wed, 3 Oct 2018 03:43:27 +0200 Subject: [PATCH] Make Mosquito Hunter use a generic counter --- data/achievements.xml | 2 +- src/achievements/achievements_status.cpp | 8 ++++++++ src/achievements/achievements_status.hpp | 5 ++++- src/items/swatter.cpp | 6 +++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/data/achievements.xml b/data/achievements.xml index 70b28579e..e77929894 100644 --- a/data/achievements.xml +++ b/data/achievements.xml @@ -62,7 +62,7 @@ name="It's secret" description="Really ... a secret."> + name="Mosquito Hunter" description="Take your opponents for mosquitos! With the swatter, squash them at least 5 times in a race."> increase("ball", "ball", m_variables[BOWLING_HIT].counter); } + Achievement *mosquito = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_MOSQUITO); + if (!mosquito->isAchieved()) + { + mosquito->reset(); + mosquito->increase("swatter", "swatter", m_variables[SWATTER_HIT_1RACE].counter); + } + Achievement *columbus = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_COLUMBUS); if (!columbus->isAchieved()) { @@ -386,6 +393,7 @@ void AchievementsStatus::onRaceEnd(bool aborted) m_variables[ACHIEVE_BANANA_1RACE].counter = 0; m_variables[ACHIEVE_SKIDDING_1RACE].counter = 0; m_variables[BOWLING_HIT_1RACE].counter = 0; + m_variables[SWATTER_HIT_1RACE].counter = 0; // Prevent restart from being abused to get consecutive wins achievement diff --git a/src/achievements/achievements_status.hpp b/src/achievements/achievements_status.hpp index cb2a0c67f..d9361e77e 100644 --- a/src/achievements/achievements_status.hpp +++ b/src/achievements/achievements_status.hpp @@ -78,8 +78,11 @@ public : // Count how many times a bowling ball from the player hit a kart BOWLING_HIT = 21, BOWLING_HIT_1RACE = 22, + // Count how many times a swatter from the player hit a kart + SWATTER_HIT = 23, + SWATTER_HIT_1RACE = 24, - ACHIEVE_DATA_NUM = 23 + ACHIEVE_DATA_NUM = 25 }; private: diff --git a/src/items/swatter.cpp b/src/items/swatter.cpp index b5d61a450..dc3c79ba4 100644 --- a/src/items/swatter.cpp +++ b/src/items/swatter.cpp @@ -25,7 +25,7 @@ // TODO: move some constants to KartProperties, use all constants from KartProperties #include "items/swatter.hpp" -#include "achievements/achievement_info.hpp" +#include "achievements/achievements_status.hpp" #include "audio/sfx_base.hpp" #include "audio/sfx_manager.hpp" #include "config/player_manager.hpp" @@ -362,8 +362,8 @@ void Swatter::squashThingsAround() // Handle achievement if the swatter is used by the current player if (m_kart->getController()->canGetAchievements()) { - PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_MOSQUITO, - "swatter", 1); + PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT, 1); + PlayerManager::increaseAchievement(AchievementsStatus::SWATTER_HIT_1RACE, 1); } if (m_closest_kart->getAttachment()->getType()==Attachment::ATTACH_BOMB)