X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FHero.h;h=2016396a4458d605c58c0d7fc77919c17f407791;hb=8f4cb4e8ad954ba73fb78a030c969c933a7ed60c;hp=dcbc7827547604a8f3a34a4541a51361e251a429;hpb=5795ffa948c6e39a624c4fc7773a99afb87579e1;p=l2e.git diff --git a/src/common/Hero.h b/src/common/Hero.h index dcbc782..2016396 100644 --- a/src/common/Hero.h +++ b/src/common/Hero.h @@ -1,16 +1,16 @@ -/* - * Hero.h - * - * Created on: Oct 7, 2012 - * Author: holy - */ - #ifndef COMMON_HERO_H_ #define COMMON_HERO_H_ -#include "fwd.h" +namespace common { + class Item; + class Spell; +} +namespace graphics { + class Animation; + class Sprite; +} + #include "Stats.h" -#include "../graphics/fwd.h" #include "../map/Entity.h" #include @@ -27,6 +27,29 @@ public: ~Hero() { } public: + enum EquipSlot { + EQUIP_WEAPON, + EQUIP_ARMOR, + EQUIP_SHIELD, + EQUIP_HELMET, + EQUIP_RING, + EQUIP_JEWEL, + EQUIP_COUNT, + }; + + enum UpgradeType { + UPGRADE_LVL, + UPGRADE_MHP, + UPGRADE_MMP, + UPGRADE_ATK, + UPGRADE_DFP, + UPGRADE_STR, + UPGRADE_AGL, + UPGRADE_INT, + UPGRADE_GUT, + UPGRADE_MGR, + }; + const char *Name() const { return name; } Uint16 MaxHealth() const { return maxHealth; } @@ -50,36 +73,21 @@ public: int Experience() const { return experience; } int NextLevel() const; + struct UpgradeInfo { + UpgradeType type; + int amount; + UpgradeInfo(UpgradeType t, int a = 0) + : type(t), amount(a) { } + }; + void AddExperience(int, std::vector &); + bool CanEquip(const Item &) const; bool CanInvoke(const Spell &) const; - Item *Weapon() { return weapon; } - Item *Armor() { return armor; } - Item *Shield() { return shield; } - Item *Helmet() { return helmet; } - Item *Ring() { return ring; } - Item *Jewel() { return jewel; } - - const Item *Weapon() const { return weapon; } - const Item *Armor() const { return armor; } - const Item *Shield() const { return shield; } - const Item *Helmet() const { return helmet; } - const Item *Ring() const { return ring; } - const Item *Jewel() const { return jewel; } - - bool HasWeapon() const { return weapon; } - bool HasArmor() const { return armor; } - bool HasShield() const { return shield; } - bool HasHelmet() const { return helmet; } - bool HasRing() const { return ring; } - bool HasJewel() const { return jewel; } - - void RemoveWeapon() { weapon = 0; } - void RemoveArmor() { armor = 0; } - void RemoveShield() { shield = 0; } - void RemoveHelmet() { helmet = 0; } - void RemoveRing() { ring = 0; } - void RemoveJewel() { jewel = 0; } + const Item *Equipment(EquipSlot i) const { return equipment[i]; } + bool Equipped(EquipSlot i) const { return equipment[i]; } + void RemoveEquipment(EquipSlot i) { equipment[i] = 0; } + void SetEquipment(EquipSlot i, const Item *item) { equipment[i] = item; } std::vector &Spells() { return spells; } const std::vector &Spells() const { return spells; } @@ -96,15 +104,9 @@ public: static void CreateTypeDescription(); static void Construct(void *); -// temporary setters public: - void SetWeapon(common::Item *i) { weapon = i; } - void SetArmor(common::Item *i) { armor = i; } - void SetShield(common::Item *i) { shield = i; } - void SetHelmet(common::Item *i) { helmet = i; } - void SetRing(common::Item *i) { ring = i; } - void SetJewel(common::Item *i) { jewel = i; } - + void SetMaxHealth(int h) { maxHealth = h; } + void SetHealth(int h) { health = h; } void AddSpell(Spell *s) { spells.push_back(s); } private: @@ -119,17 +121,13 @@ private: int level; int experience; + // TODO: ladder should contain hp, mp, and stats mods. int *levelLadder; int numLevels; int useMask; - Item *weapon; - Item *armor; - Item *shield; - Item *helmet; - Item *ring; - Item *jewel; + const Item *equipment[EQUIP_COUNT]; // TODO: vector does not seem to be a good choice std::vector spells; @@ -145,4 +143,4 @@ private: } -#endif /* COMMON_HERO_H_ */ +#endif