the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at master 103 lines 2.9 kB view raw
1#pragma once 2class Stat; 3class Achievement; 4class StatsSyncher; 5class User; 6using namespace std; 7 8class StatsCounter 9{ 10private: 11 12 enum eDifficulty 13 { 14 eDifficulty_Peaceful=0, 15 eDifficulty_Easy, 16 eDifficulty_Normal, 17 eDifficulty_Hard, 18 eDifficulty_Max 19 }; 20 21 struct StatContainer 22 { 23 unsigned int stats[eDifficulty_Max]; 24 25 StatContainer() 26 { 27 stats[eDifficulty_Peaceful] = stats[eDifficulty_Easy] = stats[eDifficulty_Normal] = stats[eDifficulty_Hard] = 0; 28 } 29 }; 30 31 typedef unordered_map<Stat*, StatContainer> StatsMap; 32 33 //static const int STAT_DATA_OFFSET = 32; 34 static const int LARGE_STATS_COUNT = 8; 35 static Stat** LARGE_STATS[LARGE_STATS_COUNT]; 36 static const int SAVE_DELAY = 30*60; 37 static const int FLUSH_DELAY = 30*60*5; 38 39 typedef enum { 40 LEADERBOARD_KILLS_PEACEFUL = 0x00000001, 41 LEADERBOARD_KILLS_EASY = 0x00000002, 42 LEADERBOARD_KILLS_NORMAL = 0x00000004, 43 LEADERBOARD_KILLS_HARD = 0x00000008, 44 LEADERBOARD_MININGBLOCKS_PEACEFUL = 0x00000010, 45 LEADERBOARD_MININGBLOCKS_EASY = 0x00000020, 46 LEADERBOARD_MININGBLOCKS_NORMAL = 0x00000040, 47 LEADERBOARD_MININGBLOCKS_HARD = 0x00000080, 48 LEADERBOARD_MININGORE_PEACEFUL = 0x00000100, 49 LEADERBOARD_MININGORE_EASY = 0x00000200, 50 LEADERBOARD_MININGORE_NORMAL = 0x00000400, 51 LEADERBOARD_MININGORE_HARD = 0x00000800, 52 LEADERBOARD_FARMING_PEACEFUL = 0x00001000, 53 LEADERBOARD_FARMING_EASY = 0x00002000, 54 LEADERBOARD_FARMING_NORMAL = 0x00004000, 55 LEADERBOARD_FARMING_HARD = 0x00008000, 56 LEADERBOARD_TRAVELLING_PEACEFUL = 0x00010000, 57 LEADERBOARD_TRAVELLING_EASY = 0x00020000, 58 LEADERBOARD_TRAVELLING_NORMAL = 0x00040000, 59 LEADERBOARD_TRAVELLING_HARD = 0x00080000, 60 LEADERBOARD_NETHER_PEACEFUL = 0x00100000, 61 LEADERBOARD_NETHER_EASY = 0x00200000, 62 LEADERBOARD_NETHER_NORMAL = 0x00400000, 63 LEADERBOARD_NETHER_HARD = 0x00800000, 64 LEADERBOARD_TRAVELLING_TOTAL = 0x01000000 65 } LEADERBOARD_FLAG; 66 67 StatsMap stats; 68 bool requiresSave; 69 int saveCounter; 70 71 int modifiedBoards; 72 static unordered_map<Stat*, int> statBoards; 73 int flushCounter; 74 75public: 76 StatsCounter(); 77 void award(Stat *stat, unsigned int difficulty, unsigned int count); 78 bool hasTaken(Achievement *ach); 79 bool canTake(Achievement *ach); 80 unsigned int getValue(Stat *stat, unsigned int difficulty); 81 unsigned int getTotalValue(Stat *stat); 82 void tick(int player); 83 void parse(void* data); 84 void clear(); 85 void save(int player, bool force=false); 86 void flushLeaderboards(); 87 void saveLeaderboards(); 88 static void setupStatBoards(); 89#ifdef _DEBUG 90 void WipeLeaderboards(); 91#endif 92 93private: 94 bool isLargeStat(Stat* stat); 95 void dumpStatsToTTY(); 96 97#ifdef _XBOX 98 static void setLeaderboardProperty(XUSER_PROPERTY* prop, DWORD id, unsigned int value); 99 static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value); 100#endif 101 102 void writeStats(); 103};