diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2021-05-04 17:11:56 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2021-05-04 17:11:56 +0200 |
commit | 34bf5c0d9db195edf8b576d1273876966cf650b2 (patch) | |
tree | b9682f8226fef09d3625089ba06235f93ce5c976 /src/StatisticsManager.cpp | |
parent | Add player statistics to API (#5193) (diff) | |
download | cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.gz cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.bz2 cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.lz cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.xz cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.tar.zst cuberite-34bf5c0d9db195edf8b576d1273876966cf650b2.zip |
Diffstat (limited to 'src/StatisticsManager.cpp')
-rw-r--r-- | src/StatisticsManager.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/StatisticsManager.cpp b/src/StatisticsManager.cpp new file mode 100644 index 000000000..0b343cb76 --- /dev/null +++ b/src/StatisticsManager.cpp @@ -0,0 +1,64 @@ + +// Statistics.cpp + +#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules + +#include "StatisticsManager.h" + + + + + +bool StatisticsManager::SatisfiesPrerequisite(const CustomStatistic a_Stat) const +{ + switch (a_Stat) + { + 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"); + } +} + + + + + +bool StatisticsManager::IsStatisticPresent(const CustomStatistic a_Stat) const +{ + const auto Result = Custom.find(a_Stat); + if (Result != Custom.end()) + { + return Result->second > 0; + } + return false; +} |