4 * Created on: Oct 7, 2012
13 #include "../graphics/fwd.h"
14 #include "../map/Entity.h"
23 static const int TYPE_ID = 301;
30 const char *Name() const { return name; }
32 Uint16 MaxHealth() const { return maxHealth; }
33 Uint16 Health() const { return health; }
34 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
35 void SubtractHealth(int amount);
37 Uint16 MaxMana() const { return maxMana; }
38 Uint16 Mana() const { return mana; }
39 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
40 bool CanUseMagic() const { return MaxMana() > 0; }
42 Uint8 MaxIP() const { return 255; }
43 Uint8 IP() const { return ip; }
44 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
46 Stats &GetStats() { return stats; }
47 const Stats &GetStats() const { return stats; }
49 Uint8 Level() const { return level; }
50 int Experience() const { return experience; }
51 int NextLevel() const;
53 bool CanEquip(const Item &) const;
54 bool CanInvoke(const Spell &) const;
56 Item *Weapon() { return weapon; }
57 Item *Armor() { return armor; }
58 Item *Shield() { return shield; }
59 Item *Helmet() { return helmet; }
60 Item *Ring() { return ring; }
61 Item *Jewel() { return jewel; }
63 const Item *Weapon() const { return weapon; }
64 const Item *Armor() const { return armor; }
65 const Item *Shield() const { return shield; }
66 const Item *Helmet() const { return helmet; }
67 const Item *Ring() const { return ring; }
68 const Item *Jewel() const { return jewel; }
70 bool HasWeapon() const { return weapon; }
71 bool HasArmor() const { return armor; }
72 bool HasShield() const { return shield; }
73 bool HasHelmet() const { return helmet; }
74 bool HasRing() const { return ring; }
75 bool HasJewel() const { return jewel; }
77 void RemoveWeapon() { weapon = 0; }
78 void RemoveArmor() { armor = 0; }
79 void RemoveShield() { shield = 0; }
80 void RemoveHelmet() { helmet = 0; }
81 void RemoveRing() { ring = 0; }
82 void RemoveJewel() { jewel = 0; }
84 std::vector<const Spell *> &Spells() { return spells; }
85 const std::vector<const Spell *> &Spells() const { return spells; }
87 graphics::Sprite *BattleSprite() { return battleSprite; }
88 const graphics::Sprite *BattleSprite() const { return battleSprite; }
89 graphics::Animation *MeleeAnimation() { return meleeAnimation; }
90 graphics::Animation *AttackAnimation() { return attackAnimation; }
91 graphics::Animation *SpellAnimation() { return spellAnimation; }
93 map::Entity &MapEntity() { return mapEntity; }
94 const map::Entity &MapEntity() const { return mapEntity; }
96 static void CreateTypeDescription();
97 static void Construct(void *);
101 void SetWeapon(common::Item *i) { weapon = i; }
102 void SetArmor(common::Item *i) { armor = i; }
103 void SetShield(common::Item *i) { shield = i; }
104 void SetHelmet(common::Item *i) { helmet = i; }
105 void SetRing(common::Item *i) { ring = i; }
106 void SetJewel(common::Item *i) { jewel = i; }
108 void AddSpell(Spell *s) { spells.push_back(s); }
113 int maxHealth, health;
134 // TODO: vector does not seem to be a good choice
135 std::vector<const Spell *> spells;
137 graphics::Sprite *battleSprite;
138 graphics::Animation *meleeAnimation;
139 graphics::Animation *attackAnimation;
140 graphics::Animation *spellAnimation;
142 map::Entity mapEntity;
148 #endif /* COMMON_HERO_H_ */