4 * Created on: Aug 6, 2012
12 #include "AttackChoice.h"
14 #include "../common/fwd.h"
15 #include "../geometry/Vector.h"
16 #include "../graphics/Animation.h"
17 #include "../graphics/fwd.h"
18 #include "../graphics/Menu.h"
32 const char *Name() const { return name; }
33 Uint8 Level() const { return level; }
34 const graphics::Sprite *Sprite() const { return sprite; }
36 const std::vector<const common::Spell *> &Spells() const { return spells; }
38 Uint16 MaxHealth() const { return maxHealth; }
39 Uint16 Health() const { return health; }
40 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
41 void SubtractHealth(int amount);
43 Uint16 MaxMana() const { return maxMana; }
44 Uint16 Mana() const { return mana; }
45 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
46 bool CanUseMagic() const { return MaxMana() > 0; }
48 Uint8 MaxIP() const { return 255; }
49 Uint8 IP() const { return ip; }
50 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
52 Stats &GetStats() { return stats; }
53 const Stats &GetStats() const { return stats; }
55 common::Item *Weapon() { return weapon; }
56 common::Item *Armor() { return armor; }
57 common::Item *Shield() { return shield; }
58 common::Item *Helmet() { return helmet; }
59 common::Item *Ring() { return ring; }
60 common::Item *Jewel() { return jewel; }
62 const common::Item *Weapon() const { return weapon; }
63 const common::Item *Armor() const { return armor; }
64 const common::Item *Shield() const { return shield; }
65 const common::Item *Helmet() const { return helmet; }
66 const common::Item *Ring() const { return ring; }
67 const common::Item *Jewel() const { return jewel; }
69 bool HasWeapon() const { return weapon; }
70 bool HasArmor() const { return armor; }
71 bool HasShield() const { return shield; }
72 bool HasHelmet() const { return helmet; }
73 bool HasRing() const { return ring; }
74 bool HasJewel() const { return jewel; }
76 graphics::AnimationRunner &GetAnimation() { return animation; }
77 const graphics::AnimationRunner &GetAnimation() const { return animation; }
78 void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
80 const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
81 const graphics::Animation *AttackAnimation() const { return attackAnimation; }
82 const graphics::Animation *SpellAnimation() const { return spellAnimation; }
84 geometry::Vector<int> &Position() { return position; }
85 const geometry::Vector<int> &Position() const { return position; }
87 graphics::Menu<const common::Spell *> &SpellMenu() { return spellMenu; }
88 const graphics::Menu<const common::Spell *> &SpellMenu() const { return spellMenu; }
89 graphics::Menu<const common::Item *> &IkariMenu() { return ikariMenu; }
90 const graphics::Menu<const common::Item *> &IkariMenu() const { return ikariMenu; }
92 AttackChoice &GetAttackChoice() { return attackChoice; }
93 const AttackChoice &GetAttackChoice() const { return attackChoice; }
96 void UpdateSpellMenu();
97 void UpdateIkariMenu(const Resources *);
99 // temporary setters until loader is implemented
101 void SetName(const char *n) { name = n; }
102 void SetLevel(Uint8 l) { level = l; }
103 void SetSprite(graphics::Sprite *s) { sprite = s; }
105 void SetMaxHealth(Uint16 h) { maxHealth = h; }
106 void SetHealth(Uint16 h) { health = h; }
107 void SetMaxMana(Uint16 m) { maxMana = m; }
108 void SetMana(Uint16 m) { mana = m; }
109 void SetIP(Uint8 i) { ip = i; }
111 void SetStats(const Stats &s) { stats = s; }
113 void SetWeapon(common::Item *i) { weapon = i; }
114 void SetArmor(common::Item *i) { armor = i; }
115 void SetShield(common::Item *i) { shield = i; }
116 void SetHelmet(common::Item *i) { helmet = i; }
117 void SetRing(common::Item *i) { ring = i; }
118 void SetJewel(common::Item *i) { jewel = i; }
120 void AddSpell(const common::Spell *s) { spells.push_back(s); }
122 void SetMeleeAnimation(const graphics::Animation *a) { meleeAnimation = a; }
123 void SetAttackAnimation(const graphics::Animation *a) { attackAnimation = a; }
124 void SetSpellAnimation(const graphics::Animation *a) { spellAnimation = a; }
126 static void CreateTypeDescription();
127 static void Construct(void *);
131 graphics::Sprite *sprite;
133 common::Item *weapon;
135 common::Item *shield;
136 common::Item *helmet;
140 const graphics::Animation *meleeAnimation;
141 const graphics::Animation *attackAnimation;
142 const graphics::Animation *spellAnimation;
144 graphics::AnimationRunner animation;
146 geometry::Vector<int> position;
148 graphics::Menu<const common::Spell *> spellMenu;
149 graphics::Menu<const common::Item *> ikariMenu;
151 AttackChoice attackChoice;
153 // TODO: vector does not seem to be a good choice
154 std::vector<const common::Spell *> spells;
156 int maxHealth, health;
168 #endif /* BATTLE_HERO_H_ */