4 * Created on: Oct 7, 2012
13 #include "../graphics/fwd.h"
14 #include "../map/Entity.h"
23 static const int TYPE_ID = 301;
40 const char *Name() const { return name; }
42 Uint16 MaxHealth() const { return maxHealth; }
43 Uint16 Health() const { return health; }
44 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
45 void SubtractHealth(int amount);
47 Uint16 MaxMana() const { return maxMana; }
48 Uint16 Mana() const { return mana; }
49 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
50 bool CanUseMagic() const { return MaxMana() > 0; }
52 Uint8 MaxIP() const { return 255; }
53 Uint8 IP() const { return ip; }
54 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
56 Stats &GetStats() { return stats; }
57 const Stats &GetStats() const { return stats; }
59 Uint8 Level() const { return level; }
60 int Experience() const { return experience; }
61 int NextLevel() const;
63 bool CanEquip(const Item &) const;
64 bool CanInvoke(const Spell &) const;
66 const Item *Equipment(EquipSlot i) const { return equipment[i]; }
67 bool Equipped(EquipSlot i) const { return equipment[i]; }
68 void RemoveEquipment(EquipSlot i) { equipment[i] = 0; }
69 void SetEquipment(EquipSlot i, const Item *item) { equipment[i] = item; }
71 std::vector<const Spell *> &Spells() { return spells; }
72 const std::vector<const Spell *> &Spells() const { return spells; }
74 graphics::Sprite *BattleSprite() { return battleSprite; }
75 const graphics::Sprite *BattleSprite() const { return battleSprite; }
76 graphics::Animation *MeleeAnimation() { return meleeAnimation; }
77 graphics::Animation *AttackAnimation() { return attackAnimation; }
78 graphics::Animation *SpellAnimation() { return spellAnimation; }
80 map::Entity &MapEntity() { return mapEntity; }
81 const map::Entity &MapEntity() const { return mapEntity; }
83 static void CreateTypeDescription();
84 static void Construct(void *);
88 void AddSpell(Spell *s) { spells.push_back(s); }
93 int maxHealth, health;
107 const Item *equipment[EQUIP_COUNT];
109 // TODO: vector does not seem to be a good choice
110 std::vector<const Spell *> spells;
112 graphics::Sprite *battleSprite;
113 graphics::Animation *meleeAnimation;
114 graphics::Animation *attackAnimation;
115 graphics::Animation *spellAnimation;
117 map::Entity mapEntity;
123 #endif /* COMMON_HERO_H_ */