summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Statistics.cpp139
-rw-r--r--src/Statistics.h116
2 files changed, 255 insertions, 0 deletions
diff --git a/src/Statistics.cpp b/src/Statistics.cpp
new file mode 100644
index 000000000..2c980d98e
--- /dev/null
+++ b/src/Statistics.cpp
@@ -0,0 +1,139 @@
+
+// Statistics.cpp
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "Statistics.h"
+
+
+
+cStatInfo cStatInfo::ms_Info[statCount] = {
+ // The order must match the order of enum eStatistic
+
+ // http://minecraft.gamepedia.com/Achievements
+
+ /* Type | Name | Prerequisite */
+ cStatInfo(achOpenInv, "openInventory"),
+ cStatInfo(achMineWood, "mineWood", achOpenInv),
+ cStatInfo(achCraftWorkbench, "buildWorkBench", achMineWood),
+ cStatInfo(achCraftPickaxe, "buildPickaxe", achCraftWorkbench),
+ cStatInfo(achCraftFurnace, "buildFurnace", achCraftPickaxe),
+ cStatInfo(achAcquireIron, "acquireIron", achCraftFurnace),
+ cStatInfo(achCraftHoe, "buildHoe", achCraftWorkbench),
+ cStatInfo(achMakeBread, "makeBread", achCraftHoe),
+ cStatInfo(achBakeCake, "bakeCake", achCraftHoe),
+ cStatInfo(achCraftBetterPick, "buildBetterPickaxe", achCraftPickaxe),
+ cStatInfo(achCookFish, "cookFish", achAcquireIron),
+ cStatInfo(achOnARail, "onARail", achAcquireIron),
+ cStatInfo(achCraftSword, "buildSword", achCraftWorkbench),
+ cStatInfo(achKillMonster, "killEnemy", achCraftSword),
+ cStatInfo(achKillCow, "killCow", achCraftSword),
+ cStatInfo(achFlyPig, "flyPig", achKillCow),
+ cStatInfo(achSnipeSkeleton, "snipeSkeleton", achKillMonster),
+ cStatInfo(achDiamonds, "diamonds", achAcquireIron),
+ cStatInfo(achEnterPortal, "portal", achDiamonds),
+ cStatInfo(achReturnToSender, "ghast", achEnterPortal),
+ cStatInfo(achBlazeRod, "blazeRod", achEnterPortal),
+ cStatInfo(achBrewPotion, "potion", achBlazeRod),
+ cStatInfo(achEnterTheEnd, "theEnd", achBlazeRod),
+ cStatInfo(achDefeatDragon, "theEnd2", achEnterTheEnd),
+ cStatInfo(achCraftEnchantTable, "enchantments", achDiamonds),
+ cStatInfo(achOverkill, "overkill", achCraftEnchantTable),
+ cStatInfo(achBookshelf, "bookcase", achCraftEnchantTable),
+ cStatInfo(achExploreAllBiomes, "exploreAllBiomes", achEnterTheEnd),
+ cStatInfo(achSpawnWither, "spawnWither", achDefeatDragon),
+ cStatInfo(achKillWither, "killWither", achSpawnWither),
+ cStatInfo(achFullBeacon, "fullBeacon", achKillWither),
+ cStatInfo(achBreedCow, "breedCow", achKillCow),
+ cStatInfo(achThrowDiamonds, "diamondsToYou", achDiamonds),
+
+ // http://minecraft.gamepedia.com/Statistics
+
+ /* Type | Name */
+ cStatInfo(statGamesQuit, "stat.leaveGame"),
+ cStatInfo(statMinutesPlayed, "stat.playOneMinute"),
+ cStatInfo(statDistWalked, "stat.walkOnCm"),
+ cStatInfo(statDistSwum, "stat.swimOneCm"),
+ cStatInfo(statDistFallen, "stat.fallOneCm"),
+ cStatInfo(statDistClimbed, "stat.climbOneCm"),
+ cStatInfo(statDistFlown, "stat.flyOneCm"),
+ cStatInfo(statDistMinecart, "stat.minecartOneCm"),
+ cStatInfo(statDistBoat, "stat.boatOneCm"),
+ cStatInfo(statDistPig, "stat.pigOneCm"),
+ cStatInfo(statDistHorse, "stat.horseOneCm"),
+ cStatInfo(statJumps, "stat.jump"),
+ cStatInfo(statItemsDropped, "stat.drop"),
+ cStatInfo(statDamageDealt, "stat.damageDealth"),
+ cStatInfo(statDamageTaken, "stat.damageTaken"),
+ cStatInfo(statDeaths, "stat.deaths"),
+ cStatInfo(statMobKills, "stat.mobKills"),
+ cStatInfo(statAnimalsBred, "stat.animalsBred"),
+ cStatInfo(statPlayerKills, "stat.playerKills"),
+ cStatInfo(statFishCaught, "stat.fishCaught"),
+ cStatInfo(statJunkFished, "stat.junkFished"),
+ cStatInfo(statTreasureFished, "stat.treasureFished")
+};
+
+
+
+
+
+
+cStatInfo::cStatInfo()
+ : m_Type(statInvalid)
+ , m_Depends(statInvalid)
+{}
+
+
+
+
+
+cStatInfo::cStatInfo(const eStatistic a_Type, const AString & a_Name, const eStatistic a_Depends)
+ : m_Type(a_Type)
+ , m_Name(a_Name)
+ , m_Depends(a_Depends)
+{}
+
+
+
+
+
+const AString & cStatInfo::GetName(const eStatistic a_Type)
+{
+ ASSERT((a_Type > statInvalid) && (a_Type < statCount));
+
+ return ms_Info[a_Type].m_Name;
+}
+
+
+
+
+
+eStatistic cStatInfo::GetType(const AString & a_Name)
+{
+ for (unsigned int i = 0; i < ARRAYCOUNT(ms_Info); ++i)
+ {
+ if (NoCaseCompare(ms_Info[i].m_Name, a_Name))
+ {
+ return ms_Info[i].m_Type;
+ }
+ }
+
+ return statInvalid;
+}
+
+
+
+
+
+eStatistic cStatInfo::GetPrerequisite(const eStatistic a_Type)
+{
+ ASSERT((a_Type > statInvalid) && (a_Type < statCount));
+
+ return ms_Info[a_Type].m_Depends;
+}
+
+
+
+
+
diff --git a/src/Statistics.h b/src/Statistics.h
new file mode 100644
index 000000000..540df38cc
--- /dev/null
+++ b/src/Statistics.h
@@ -0,0 +1,116 @@
+
+// Statistics.h
+
+
+
+
+#pragma once
+
+
+
+
+enum eStatistic
+{
+ // The order must match the order of cStatInfo::ms_Info
+
+ statInvalid = -1,
+
+ /* Achievements */
+ achOpenInv, /* Taking Inventory */
+ achMineWood, /* Getting Wood */
+ achCraftWorkbench, /* Benchmarking */
+ achCraftPickaxe, /* Time to Mine! */
+ achCraftFurnace, /* Hot Topic */
+ achAcquireIron, /* Acquire Hardware */
+ achCraftHoe, /* Time to Farm! */
+ achMakeBread, /* Bake Bread */
+ achBakeCake, /* The Lie */
+ achCraftBetterPick, /* Getting an Upgrade */
+ achCookFish, /* Delicious Fish */
+ achOnARail, /* On A Rail */
+ achCraftSword, /* Time to Strike! */
+ achKillMonster, /* Monster Hunter */
+ achKillCow, /* Cow Tipper */
+ achFlyPig, /* When Pigs Fly */
+ achSnipeSkeleton, /* Sniper Duel */
+ achDiamonds, /* DIAMONDS! */
+ achEnterPortal, /* We Need to Go Deeper */
+ achReturnToSender, /* Return to Sender */
+ achBlazeRod, /* Into Fire */
+ achBrewPotion, /* Local Brewery */
+ achEnterTheEnd, /* The End? */
+ achDefeatDragon, /* The End. */
+ achCraftEnchantTable, /* Enchanter */
+ achOverkill, /* Overkill */
+ achBookshelf, /* Librarian */
+ achExploreAllBiomes, /* Adventuring Time */
+ achSpawnWither, /* The Beginning? */
+ achKillWither, /* The Beginning. */
+ achFullBeacon, /* Beaconator */
+ achBreedCow, /* Repopulation */
+ achThrowDiamonds, /* Diamonds to you! */
+
+ /* Statistics */
+ statGamesQuit,
+ statMinutesPlayed,
+ statDistWalked,
+ statDistSwum,
+ statDistFallen,
+ statDistClimbed,
+ statDistFlown,
+ statDistDove,
+ statDistMinecart,
+ statDistBoat,
+ statDistPig,
+ statDistHorse,
+ statJumps,
+ statItemsDropped,
+ statDamageDealt,
+ statDamageTaken,
+ statDeaths,
+ statMobKills,
+ statAnimalsBred,
+ statPlayerKills,
+ statFishCaught,
+ statJunkFished,
+ statTreasureFished,
+
+ statCount
+};
+
+
+
+
+
+
+/** Class used to store and query statistic-related information. */
+class cStatInfo
+{
+public:
+
+ cStatInfo();
+
+ cStatInfo(const eStatistic a_Type, const AString & a_Name, const eStatistic a_Depends = statInvalid);
+
+ /** Type -> Name */
+ static const AString & GetName(const eStatistic a_Type);
+
+ /** Name -> Type */
+ static eStatistic GetType(const AString & a_Name);
+
+ /** Returns stat prerequisite. (Used for achievements) */
+ static eStatistic GetPrerequisite(const eStatistic a_Type);
+
+private:
+
+ eStatistic m_Type;
+
+ AString m_Name;
+
+ eStatistic m_Depends;
+
+ static cStatInfo ms_Info[statCount];
+};
+
+
+