4 * Created on: Oct 7, 2012
13 #include "../graphics/fwd.h"
26 const char *Name() const { return name; }
28 Uint16 MaxHealth() const { return maxHealth; }
29 Uint16 Health() const { return health; }
30 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
31 void SubtractHealth(int amount);
33 Uint16 MaxMana() const { return maxMana; }
34 Uint16 Mana() const { return mana; }
35 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
36 bool CanUseMagic() const { return MaxMana() > 0; }
38 Uint8 MaxIP() const { return 255; }
39 Uint8 IP() const { return ip; }
40 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
42 Stats &GetStats() { return stats; }
43 const Stats &GetStats() const { return stats; }
45 Uint8 Level() const { return level; }
47 Item *Weapon() { return weapon; }
48 Item *Armor() { return armor; }
49 Item *Shield() { return shield; }
50 Item *Helmet() { return helmet; }
51 Item *Ring() { return ring; }
52 Item *Jewel() { return jewel; }
54 const Item *Weapon() const { return weapon; }
55 const Item *Armor() const { return armor; }
56 const Item *Shield() const { return shield; }
57 const Item *Helmet() const { return helmet; }
58 const Item *Ring() const { return ring; }
59 const Item *Jewel() const { return jewel; }
61 bool HasWeapon() const { return weapon; }
62 bool HasArmor() const { return armor; }
63 bool HasShield() const { return shield; }
64 bool HasHelmet() const { return helmet; }
65 bool HasRing() const { return ring; }
66 bool HasJewel() const { return jewel; }
68 const std::vector<const Spell *> &Spells() const { return spells; }
70 graphics::Sprite *BattleSprite() { return battleSprite; }
71 graphics::Animation *MeleeAnimation() { return meleeAnimation; }
72 graphics::Animation *AttackAnimation() { return attackAnimation; }
73 graphics::Animation *SpellAnimation() { return spellAnimation; }
75 graphics::Sprite *MapSprite() { return mapSprite; }
77 static void CreateTypeDescription();
78 static void Construct(void *);
82 void SetWeapon(common::Item *i) { weapon = i; }
83 void SetArmor(common::Item *i) { armor = i; }
84 void SetShield(common::Item *i) { shield = i; }
85 void SetHelmet(common::Item *i) { helmet = i; }
86 void SetRing(common::Item *i) { ring = i; }
87 void SetJewel(common::Item *i) { jewel = i; }
89 void AddSpell(Spell *s) { spells.push_back(s); }
94 int maxHealth, health;
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 graphics::Sprite *mapSprite;
123 #endif /* COMMON_HERO_H_ */