diff options
Diffstat (limited to 'src/Statistics.cpp')
-rw-r--r-- | src/Statistics.cpp | 92 |
1 files changed, 37 insertions, 55 deletions
diff --git a/src/Statistics.cpp b/src/Statistics.cpp index 7bc5ae413..f037ec7b1 100644 --- a/src/Statistics.cpp +++ b/src/Statistics.cpp @@ -9,61 +9,43 @@ -void cStatManager::SetValue(const Statistic a_Stat, const StatValue a_Value) -{ - m_CustomStatistics[a_Stat] = a_Value; -} - - - - - -cStatManager::StatValue cStatManager::AddValue(const Statistic a_Stat, const StatValue a_Delta) -{ - return m_CustomStatistics[a_Stat] += a_Delta; -} - - - - - -bool cStatManager::SatisfiesPrerequisite(const Statistic a_Stat) +bool StatisticsManager::SatisfiesPrerequisite(const CustomStatistic a_Stat) const { switch (a_Stat) { - case Statistic::AchMineWood: return IsStatisticPresent(Statistic::AchOpenInventory); - case Statistic::AchBuildWorkBench: return IsStatisticPresent(Statistic::AchMineWood); - case Statistic::AchBuildHoe: return IsStatisticPresent(Statistic::AchBuildWorkBench); - case Statistic::AchBakeCake: return IsStatisticPresent(Statistic::AchBuildHoe); - case Statistic::AchMakeBread: return IsStatisticPresent(Statistic::AchBuildHoe); - case Statistic::AchBuildSword: return IsStatisticPresent(Statistic::AchBuildWorkBench); - case Statistic::AchKillCow: return IsStatisticPresent(Statistic::AchBuildSword); - case Statistic::AchFlyPig: return IsStatisticPresent(Statistic::AchKillCow); - case Statistic::AchBreedCow: return IsStatisticPresent(Statistic::AchKillCow); - case Statistic::AchKillEnemy: return IsStatisticPresent(Statistic::AchBuildSword); - case Statistic::AchSnipeSkeleton: return IsStatisticPresent(Statistic::AchKillEnemy); - case Statistic::AchBuildPickaxe: return IsStatisticPresent(Statistic::AchBuildWorkBench); - case Statistic::AchBuildBetterPickaxe: return IsStatisticPresent(Statistic::AchBuildPickaxe); - case Statistic::AchBuildFurnace: return IsStatisticPresent(Statistic::AchBuildWorkBench); - case Statistic::AchCookFish: return IsStatisticPresent(Statistic::AchBuildFurnace); - case Statistic::AchAcquireIron: return IsStatisticPresent(Statistic::AchBuildFurnace); - case Statistic::AchOnARail: return IsStatisticPresent(Statistic::AchAcquireIron); - case Statistic::AchDiamonds: return IsStatisticPresent(Statistic::AchAcquireIron); - case Statistic::AchPortal: return IsStatisticPresent(Statistic::AchDiamonds); - case Statistic::AchGhast: return IsStatisticPresent(Statistic::AchPortal); - case Statistic::AchBlazeRod: return IsStatisticPresent(Statistic::AchPortal); - case Statistic::AchPotion: return IsStatisticPresent(Statistic::AchBlazeRod); - case Statistic::AchTheEnd: return IsStatisticPresent(Statistic::AchBlazeRod); - case Statistic::AchTheEnd2: return IsStatisticPresent(Statistic::AchTheEnd); - case Statistic::AchEnchantments: return IsStatisticPresent(Statistic::AchDiamonds); - case Statistic::AchOverkill: return IsStatisticPresent(Statistic::AchEnchantments); - case Statistic::AchBookcase: return IsStatisticPresent(Statistic::AchEnchantments); - case Statistic::AchExploreAllBiomes: return IsStatisticPresent(Statistic::AchTheEnd); - case Statistic::AchSpawnWither: return IsStatisticPresent(Statistic::AchTheEnd2); - case Statistic::AchKillWither: return IsStatisticPresent(Statistic::AchSpawnWither); - case Statistic::AchFullBeacon: return IsStatisticPresent(Statistic::AchKillWither); - case Statistic::AchDiamondsToYou: return IsStatisticPresent(Statistic::AchDiamonds); - default: return true; + case CustomStatistic::AchMineWood: return IsStatisticPresent(CustomStatistic::AchOpenInventory); + case CustomStatistic::AchBuildWorkBench: return IsStatisticPresent(CustomStatistic::AchMineWood); + case CustomStatistic::AchBuildHoe: return IsStatisticPresent(CustomStatistic::AchBuildWorkBench); + case CustomStatistic::AchBakeCake: return IsStatisticPresent(CustomStatistic::AchBuildHoe); + case CustomStatistic::AchMakeBread: return IsStatisticPresent(CustomStatistic::AchBuildHoe); + case CustomStatistic::AchBuildSword: return IsStatisticPresent(CustomStatistic::AchBuildWorkBench); + case CustomStatistic::AchKillCow: return IsStatisticPresent(CustomStatistic::AchBuildSword); + case CustomStatistic::AchFlyPig: return IsStatisticPresent(CustomStatistic::AchKillCow); + case CustomStatistic::AchBreedCow: return IsStatisticPresent(CustomStatistic::AchKillCow); + case CustomStatistic::AchKillEnemy: return IsStatisticPresent(CustomStatistic::AchBuildSword); + case CustomStatistic::AchSnipeSkeleton: return IsStatisticPresent(CustomStatistic::AchKillEnemy); + case CustomStatistic::AchBuildPickaxe: return IsStatisticPresent(CustomStatistic::AchBuildWorkBench); + case CustomStatistic::AchBuildBetterPickaxe: return IsStatisticPresent(CustomStatistic::AchBuildPickaxe); + case CustomStatistic::AchBuildFurnace: return IsStatisticPresent(CustomStatistic::AchBuildWorkBench); + case CustomStatistic::AchCookFish: return IsStatisticPresent(CustomStatistic::AchBuildFurnace); + case CustomStatistic::AchAcquireIron: return IsStatisticPresent(CustomStatistic::AchBuildFurnace); + case CustomStatistic::AchOnARail: return IsStatisticPresent(CustomStatistic::AchAcquireIron); + case CustomStatistic::AchDiamonds: return IsStatisticPresent(CustomStatistic::AchAcquireIron); + case CustomStatistic::AchPortal: return IsStatisticPresent(CustomStatistic::AchDiamonds); + case CustomStatistic::AchGhast: return IsStatisticPresent(CustomStatistic::AchPortal); + case CustomStatistic::AchBlazeRod: return IsStatisticPresent(CustomStatistic::AchPortal); + case CustomStatistic::AchPotion: return IsStatisticPresent(CustomStatistic::AchBlazeRod); + case CustomStatistic::AchTheEnd: return IsStatisticPresent(CustomStatistic::AchBlazeRod); + case CustomStatistic::AchTheEnd2: return IsStatisticPresent(CustomStatistic::AchTheEnd); + case CustomStatistic::AchEnchantments: return IsStatisticPresent(CustomStatistic::AchDiamonds); + case CustomStatistic::AchOverkill: return IsStatisticPresent(CustomStatistic::AchEnchantments); + case CustomStatistic::AchBookcase: return IsStatisticPresent(CustomStatistic::AchEnchantments); + case CustomStatistic::AchExploreAllBiomes: return IsStatisticPresent(CustomStatistic::AchTheEnd); + case CustomStatistic::AchSpawnWither: return IsStatisticPresent(CustomStatistic::AchTheEnd2); + case CustomStatistic::AchKillWither: return IsStatisticPresent(CustomStatistic::AchSpawnWither); + case CustomStatistic::AchFullBeacon: return IsStatisticPresent(CustomStatistic::AchKillWither); + case CustomStatistic::AchDiamondsToYou: return IsStatisticPresent(CustomStatistic::AchDiamonds); + default: UNREACHABLE("Unsupported achievement type"); } } @@ -71,10 +53,10 @@ bool cStatManager::SatisfiesPrerequisite(const Statistic a_Stat) -bool cStatManager::IsStatisticPresent(const Statistic a_Stat) const +bool StatisticsManager::IsStatisticPresent(const CustomStatistic a_Stat) const { - const auto Result = m_CustomStatistics.find(a_Stat); - if (Result != m_CustomStatistics.end()) + const auto Result = Custom.find(a_Stat); + if (Result != Custom.end()) { return Result->second > 0; } |