4 * Created on: Aug 6, 2012
12 #include "../graphics/Animation.h"
34 const char *Name() const { return name; }
35 Uint8 Level() const { return level; }
36 const graphics::Sprite *Sprite() const { return sprite; }
38 const std::vector<const common::Spell *> &Spells() const { return spells; }
40 Uint16 MaxHealth() const { return maxHealth; }
41 Uint16 Health() const { return health; }
42 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
43 void SubtractHealth(int amount);
45 Uint16 MaxMana() const { return maxMana; }
46 Uint16 Mana() const { return mana; }
47 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
48 bool CanUseMagic() const { return MaxMana() > 0; }
50 Uint8 MaxIP() const { return 255; }
51 Uint8 IP() const { return ip; }
52 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
54 Stats &GetStats() { return stats; }
55 const Stats &GetStats() const { return stats; }
57 common::Item *Weapon() { return weapon; }
58 common::Item *Armor() { return armor; }
59 common::Item *Shield() { return shield; }
60 common::Item *Helmet() { return helmet; }
61 common::Item *Ring() { return ring; }
62 common::Item *Jewel() { return jewel; }
64 const common::Item *Weapon() const { return weapon; }
65 const common::Item *Armor() const { return armor; }
66 const common::Item *Shield() const { return shield; }
67 const common::Item *Helmet() const { return helmet; }
68 const common::Item *Ring() const { return ring; }
69 const common::Item *Jewel() const { return jewel; }
71 bool HasWeapon() const { return weapon; }
72 bool HasArmor() const { return armor; }
73 bool HasShield() const { return shield; }
74 bool HasHelmet() const { return helmet; }
75 bool HasRing() const { return ring; }
76 bool HasJewel() const { return jewel; }
78 graphics::AnimationRunner &GetAnimation() { return animation; }
79 const graphics::AnimationRunner &GetAnimation() const { return animation; }
80 void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
82 const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
83 const graphics::Animation *AttackAnimation() const { return attackAnimation; }
84 const graphics::Animation *SpellAnimation() const { return spellAnimation; }
86 // temporary setters until loader is implemented
88 void SetName(const char *n) { name = n; }
89 void SetLevel(Uint8 l) { level = l; }
90 void SetSprite(graphics::Sprite *s) { sprite = s; }
92 void SetMaxHealth(Uint16 h) { maxHealth = h; }
93 void SetHealth(Uint16 h) { health = h; }
94 void SetMaxMana(Uint16 m) { maxMana = m; }
95 void SetMana(Uint16 m) { mana = m; }
96 void SetIP(Uint8 i) { ip = i; }
98 void SetStats(const Stats &s) { stats = s; }
100 void SetWeapon(common::Item *i) { weapon = i; }
101 void SetArmor(common::Item *i) { armor = i; }
102 void SetShield(common::Item *i) { shield = i; }
103 void SetHelmet(common::Item *i) { helmet = i; }
104 void SetRing(common::Item *i) { ring = i; }
105 void SetJewel(common::Item *i) { jewel = i; }
107 void AddSpell(const common::Spell *s) { spells.push_back(s); }
109 void SetMeleeAnimation(const graphics::Animation *a) { meleeAnimation = a; }
110 void SetAttackAnimation(const graphics::Animation *a) { attackAnimation = a; }
111 void SetSpellAnimation(const graphics::Animation *a) { spellAnimation = a; }
115 graphics::Sprite *sprite;
117 common::Item *weapon;
119 common::Item *shield;
120 common::Item *helmet;
124 const graphics::Animation *meleeAnimation;
125 const graphics::Animation *attackAnimation;
126 const graphics::Animation *spellAnimation;
128 graphics::AnimationRunner animation;
130 // TODO: vector does not seem to be a good choice
131 std::vector<const common::Spell *> spells;
133 Uint16 maxHealth, health;
134 Uint16 maxMana, mana;
145 #endif /* BATTLE_HERO_H_ */