summaryrefslogtreecommitdiff
path: root/src/playerinfo.h
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-07-17 23:10:05 -0600
committerJared Adams <jaxad0127@gmail.com>2010-07-18 11:45:33 -0600
commit81d8168bb5796ccb1704bcce9f5327c35e55d281 (patch)
tree3e7e111eb956757f49579bb4366c24c94712387d /src/playerinfo.h
parent2ae96bdc5517b2147662f19ff6d700657c0d0d42 (diff)
downloadmana-client-81d8168bb5796ccb1704bcce9f5327c35e55d281.tar.gz
mana-client-81d8168bb5796ccb1704bcce9f5327c35e55d281.tar.bz2
mana-client-81d8168bb5796ccb1704bcce9f5327c35e55d281.tar.xz
mana-client-81d8168bb5796ccb1704bcce9f5327c35e55d281.zip
Move more from LocalPlayer to PlayerInfo
Also cleanup PlayerInfo a bit. Reviewed-by: Chuck Miller
Diffstat (limited to 'src/playerinfo.h')
-rw-r--r--src/playerinfo.h192
1 files changed, 150 insertions, 42 deletions
diff --git a/src/playerinfo.h b/src/playerinfo.h
index 421e93bc..1c722a7c 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -24,6 +24,9 @@
#include <map>
#include <string>
+/**
+ * Standard attributes for players.
+ */
enum Attribute
{
LEVEL,
@@ -36,6 +39,9 @@ enum Attribute
CHAR_POINTS, CORR_POINTS
};
+/**
+ * Stat information storage structure.
+ */
struct Stat
{
int base;
@@ -47,59 +53,161 @@ struct Stat
typedef std::map<int, int> IntMap;
typedef std::map<int, Stat> StatMap;
+/**
+ * Backend for core player information.
+ */
struct PlayerInfoBackend
{
- public:
IntMap mAttributes;
StatMap mStats;
};
+class Equipment;
+class Inventory;
+class Item;
+
/**
- * A database like class which holds global info about the localplayer
+ * Special information storage structure.
*/
-class PlayerInfo
+struct Special
{
- // NOTE: All agruements for 'bool notify' is to determine if
- // a event is to be triggered
- public:
- static void setBackend(const PlayerInfoBackend &backend);
-
- /**
- * Attributes for things like money and exp
- */
- static int getAttribute(int id);
-
- static void setAttribute(int id, int value, bool notify = true);
-
-
- /**
- * Stats are modifiable attributes basicilly, like str, crit, trade
- */
-
- static int getStatBase(int id);
-
- static void setStatBase(int id, int value, bool notify = true);
-
- static int getStatMod(int id);
-
- static void setStatMod(int id, int value, bool notify = true);
-
- // Base + mod
- static int getStatEffective(int id);
-
- static void setStatLevel(int id, int value, bool notify = true);
-
- static std::pair<int, int> getStatExperience(int id);
-
- static void setStatExperience(int id, int have, int need, bool notify = true);
+ int currentMana;
+ int neededMana;
+ int recharge;
+};
- private:
- // Triggers send events for action.
- static void triggerAttr(int id);
+typedef std::map<int, Special> SpecialsMap;
- static void triggerStat(int id);
+/**
+ * A database like namespace which holds global info about the localplayer
+ *
+ * NOTE: 'bool notify' is used to determine if a event is to be triggered.
+ */
+namespace PlayerInfo
+{
- static PlayerInfoBackend mData;
-};
+// --- Attributes -------------------------------------------------------------
+
+ /**
+ * Returns the value of the given attribute.
+ */
+ int getAttribute(int id);
+
+ /**
+ * Changes the value of the given attribute.
+ */
+ void setAttribute(int id, int value, bool notify = true);
+
+// --- Stats ------------------------------------------------------------------
+
+ /**
+ * Returns the base value of the given stat.
+ */
+ int getStatBase(int id);
+
+ /**
+ * Changes the base value of the given stat.
+ */
+ void setStatBase(int id, int value, bool notify = true);
+
+ /**
+ * Returns the modifier for the given stat.
+ */
+ int getStatMod(int id);
+
+ /**
+ * Changes the modifier for the given stat.
+ */
+ void setStatMod(int id, int value, bool notify = true);
+
+ /**
+ * Returns the current effective value of the given stat. Effective is base
+ * + mod
+ */
+ int getStatEffective(int id);
+
+ /**
+ * Changes the level of the given stat.
+ */
+ void setStatLevel(int id, int value, bool notify = true);
+
+ /**
+ * Returns the experience of the given stat.
+ */
+ std::pair<int, int> getStatExperience(int id);
+
+ /**
+ * Changes the experience of the given stat.
+ */
+ void setStatExperience(int id, int have, int need, bool notify = true);
+
+// --- Inventory / Equipment --------------------------------------------------
+
+ /**
+ * Returns the player's inventory.
+ */
+ Inventory *getInventory();
+
+ /**
+ * Clears the player's inventory and equipment.
+ */
+ void clearInventory();
+
+ /**
+ * Changes the inventory item at the given slot.
+ */
+ void setInventoryItem(int index, int id, int amount);
+
+ /**
+ * Returns the player's equipment.
+ */
+ Equipment *getEquipment();
+
+ /**
+ * Returns the player's equipment at the given slot.
+ */
+ Item *getEquipment(unsigned int slot);
+
+// --- Specials ---------------------------------------------------------------
+
+ /**
+ * Changes the status of the given special.
+ */
+ void setSpecialStatus(int id, int current, int max, int recharge);
+
+ /**
+ * Returns the status of the given special.
+ */
+ const SpecialsMap &getSpecialStatus();
+
+// --- Misc -------------------------------------------------------------------
+
+ /**
+ * Changes the internal PlayerInfoBackend reference;
+ */
+ void setBackend(const PlayerInfoBackend &backend);
+
+ /**
+ * Does necessary updates every tick.
+ */
+ void logic();
+
+ /**
+ * Returns true if the player is involved in a trade at the moment, false
+ * otherwise.
+ */
+ bool isTrading();
+
+ /**
+ * Sets whether the player is currently involved in trade or not.
+ */
+ void setTrading(bool trading);
+
+ /**
+ * Initializes some internals.
+ */
+ void init();
+
+} // namespace PlayerInfo
#endif