4 * Created on: Aug 6, 2012
11 #include "AttackChoice.h"
13 #include "../geometry/Vector.h"
14 #include "../graphics/Animation.h"
15 #include "../graphics/Menu.h"
39 const char *Name() const { return name; }
40 Uint8 Level() const { return level; }
41 const graphics::Sprite *Sprite() const { return sprite; }
43 const std::vector<const common::Spell *> &Spells() const { return spells; }
45 Uint16 MaxHealth() const { return maxHealth; }
46 Uint16 Health() const { return health; }
47 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
48 void SubtractHealth(int amount);
50 Uint16 MaxMana() const { return maxMana; }
51 Uint16 Mana() const { return mana; }
52 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
53 bool CanUseMagic() const { return MaxMana() > 0; }
55 Uint8 MaxIP() const { return 255; }
56 Uint8 IP() const { return ip; }
57 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
59 Stats &GetStats() { return stats; }
60 const Stats &GetStats() const { return stats; }
62 common::Item *Weapon() { return weapon; }
63 common::Item *Armor() { return armor; }
64 common::Item *Shield() { return shield; }
65 common::Item *Helmet() { return helmet; }
66 common::Item *Ring() { return ring; }
67 common::Item *Jewel() { return jewel; }
69 const common::Item *Weapon() const { return weapon; }
70 const common::Item *Armor() const { return armor; }
71 const common::Item *Shield() const { return shield; }
72 const common::Item *Helmet() const { return helmet; }
73 const common::Item *Ring() const { return ring; }
74 const common::Item *Jewel() const { return jewel; }
76 bool HasWeapon() const { return weapon; }
77 bool HasArmor() const { return armor; }
78 bool HasShield() const { return shield; }
79 bool HasHelmet() const { return helmet; }
80 bool HasRing() const { return ring; }
81 bool HasJewel() const { return jewel; }
83 graphics::AnimationRunner &GetAnimation() { return animation; }
84 const graphics::AnimationRunner &GetAnimation() const { return animation; }
85 void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
87 const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
88 const graphics::Animation *AttackAnimation() const { return attackAnimation; }
89 const graphics::Animation *SpellAnimation() const { return spellAnimation; }
91 geometry::Vector<int> &Position() { return position; }
92 const geometry::Vector<int> &Position() const { return position; }
94 graphics::Menu<const common::Spell *> &SpellMenu() { return spellMenu; }
95 const graphics::Menu<const common::Spell *> &SpellMenu() const { return spellMenu; }
96 graphics::Menu<const common::Item *> &IkariMenu() { return ikariMenu; }
97 const graphics::Menu<const common::Item *> &IkariMenu() const { return ikariMenu; }
99 AttackChoice &GetAttackChoice() { return attackChoice; }
100 const AttackChoice &GetAttackChoice() const { return attackChoice; }
103 void UpdateSpellMenu();
104 void UpdateIkariMenu(const Resources *);
106 // temporary setters until loader is implemented
108 void SetName(const char *n) { name = n; }
109 void SetLevel(Uint8 l) { level = l; }
110 void SetSprite(graphics::Sprite *s) { sprite = s; }
112 void SetMaxHealth(Uint16 h) { maxHealth = h; }
113 void SetHealth(Uint16 h) { health = h; }
114 void SetMaxMana(Uint16 m) { maxMana = m; }
115 void SetMana(Uint16 m) { mana = m; }
116 void SetIP(Uint8 i) { ip = i; }
118 void SetStats(const Stats &s) { stats = s; }
120 void SetWeapon(common::Item *i) { weapon = i; }
121 void SetArmor(common::Item *i) { armor = i; }
122 void SetShield(common::Item *i) { shield = i; }
123 void SetHelmet(common::Item *i) { helmet = i; }
124 void SetRing(common::Item *i) { ring = i; }
125 void SetJewel(common::Item *i) { jewel = i; }
127 void AddSpell(const common::Spell *s) { spells.push_back(s); }
129 void SetMeleeAnimation(const graphics::Animation *a) { meleeAnimation = a; }
130 void SetAttackAnimation(const graphics::Animation *a) { attackAnimation = a; }
131 void SetSpellAnimation(const graphics::Animation *a) { spellAnimation = a; }
133 static void CreateTypeDescription();
137 graphics::Sprite *sprite;
139 common::Item *weapon;
141 common::Item *shield;
142 common::Item *helmet;
146 const graphics::Animation *meleeAnimation;
147 const graphics::Animation *attackAnimation;
148 const graphics::Animation *spellAnimation;
150 graphics::AnimationRunner animation;
152 geometry::Vector<int> position;
154 graphics::Menu<const common::Spell *> spellMenu;
155 graphics::Menu<const common::Item *> ikariMenu;
157 AttackChoice attackChoice;
159 // TODO: vector does not seem to be a good choice
160 std::vector<const common::Spell *> spells;
162 int maxHealth, health;
174 #endif /* BATTLE_HERO_H_ */