1
0
cuberite-2a/src/Statistics.cpp

83 lines
3.7 KiB
C++
Raw Normal View History

2014-04-07 09:31:15 -04:00
// Statistics.cpp
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Statistics.h"
void cStatManager::SetValue(const Statistic a_Stat, const StatValue a_Value)
2014-05-11 07:57:06 -04:00
{
m_CustomStatistics[a_Stat] = a_Value;
2014-05-11 07:57:06 -04:00
}
cStatManager::StatValue cStatManager::AddValue(const Statistic a_Stat, const StatValue a_Delta)
2014-05-11 07:57:06 -04:00
{
return m_CustomStatistics[a_Stat] += a_Delta;
2014-05-11 07:57:06 -04:00
}
bool cStatManager::SatisfiesPrerequisite(const Statistic a_Stat)
2014-05-11 07:57:06 -04:00
{
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;
}
2014-05-11 07:57:06 -04:00
}
bool cStatManager::IsStatisticPresent(const Statistic a_Stat) const
2014-05-11 07:57:06 -04:00
{
const auto Result = m_CustomStatistics.find(a_Stat);
if (Result != m_CustomStatistics.end())
2014-05-11 07:57:06 -04:00
{
return Result->second > 0;
2014-05-11 07:57:06 -04:00
}
return false;
2014-05-11 07:57:06 -04:00
}