summaryrefslogtreecommitdiffstats
path: root/src/Statistics.h
blob: 49750e8c0b12bbd28831d45d6fc6031e8ec3ed3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

// Statistics.h




#pragma once




// tolua_begin
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
};
// tolua_end






/** 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];
};




/* Signed (?) integral value. */
typedef int StatValue; // tolua_export




/** Class that manages the statistics and achievements of a single player. */
// tolua_begin
class cStatManager
{
public:
	// tolua_end

	cStatManager();

	// tolua_begin

	/** Return the value of the specified stat. */
	StatValue GetValue(const eStatistic a_Stat) const;

	/** Set the value of the specified stat. */
	void SetValue(const eStatistic a_Stat, const StatValue a_Value);

	/** Reset everything. */
	void Reset();

	/** Increments the specified stat.
	Returns the new value.
	*/
	StatValue AddValue(const eStatistic a_Stat, const StatValue a_Delta = 1);

	// tolua_end

private:

	StatValue m_MainStats[statCount];

	// TODO 10-05-2014 xdot: Use, mine, craft statistics


}; // tolua_export