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 Item *Equipment(EquipSlot i) { return equipment[i]; }
67 const Item *Equipment(EquipSlot i) const { return equipment[i]; }
68 bool Equipped(EquipSlot i) const { return equipment[i]; }
69 void RemoveEquipment(EquipSlot i) { equipment[i] = 0; }
70 void SetEquipment(EquipSlot i, Item *item) { equipment[i] = item; }
72 std::vector<const Spell *> &Spells() { return spells; }
73 const std::vector<const Spell *> &Spells() const { return spells; }
75 graphics::Sprite *BattleSprite() { return battleSprite; }
76 const graphics::Sprite *BattleSprite() const { return battleSprite; }
77 graphics::Animation *MeleeAnimation() { return meleeAnimation; }
78 graphics::Animation *AttackAnimation() { return attackAnimation; }
79 graphics::Animation *SpellAnimation() { return spellAnimation; }
81 map::Entity &MapEntity() { return mapEntity; }
82 const map::Entity &MapEntity() const { return mapEntity; }
84 static void CreateTypeDescription();
85 static void Construct(void *);
89 void AddSpell(Spell *s) { spells.push_back(s); }
94 int maxHealth, health;
108 Item *equipment[EQUIP_COUNT];
110 // TODO: vector does not seem to be a good choice
111 std::vector<const Spell *> spells;
113 graphics::Sprite *battleSprite;
114 graphics::Animation *meleeAnimation;
115 graphics::Animation *attackAnimation;
116 graphics::Animation *spellAnimation;
118 map::Entity mapEntity;
124 #endif /* COMMON_HERO_H_ */