]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
added forwarding headers
[l2e.git] / src / battle / Hero.h
1 /*
2  * Hero.h
3  *
4  *  Created on: Aug 6, 2012
5  *      Author: holy
6  */
7
8 #ifndef BATTLE_HERO_H_
9 #define BATTLE_HERO_H_
10
11 #include "fwd.h"
12 #include "AttackChoice.h"
13 #include "Stats.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"
19
20 #include <vector>
21 #include <SDL.h>
22
23 namespace battle {
24
25 class Hero {
26
27 public:
28         Hero();
29         ~Hero();
30
31 public:
32         const char *Name() const { return name; }
33         Uint8 Level() const { return level; }
34         const graphics::Sprite *Sprite() const { return sprite; }
35
36         const std::vector<const common::Spell *> &Spells() const { return spells; }
37
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);
42
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; }
47
48         Uint8 MaxIP() const { return 255; }
49         Uint8 IP() const { return ip; }
50         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
51
52         Stats &GetStats() { return stats; }
53         const Stats &GetStats() const { return stats; }
54
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; }
61
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; }
68
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; }
75
76         graphics::AnimationRunner &GetAnimation() { return animation; }
77         const graphics::AnimationRunner &GetAnimation() const { return animation; }
78         void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
79
80         const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
81         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
82         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
83
84         geometry::Vector<int> &Position() { return position; }
85         const geometry::Vector<int> &Position() const { return position; }
86
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; }
91
92         AttackChoice &GetAttackChoice() { return attackChoice; }
93         const AttackChoice &GetAttackChoice() const { return attackChoice; }
94
95 public:
96         void UpdateSpellMenu();
97         void UpdateIkariMenu(const Resources *);
98
99 // temporary setters until loader is implemented
100 public:
101         void SetName(const char *n) { name = n; }
102         void SetLevel(Uint8 l) { level = l; }
103         void SetSprite(graphics::Sprite *s) { sprite = s; }
104
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; }
110
111         void SetStats(const Stats &s) { stats = s; }
112
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; }
119
120         void AddSpell(const common::Spell *s) { spells.push_back(s); }
121
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; }
125
126         static void CreateTypeDescription();
127         static void Construct(void *);
128
129 private:
130         const char *name;
131         graphics::Sprite *sprite;
132
133         common::Item *weapon;
134         common::Item *armor;
135         common::Item *shield;
136         common::Item *helmet;
137         common::Item *ring;
138         common::Item *jewel;
139
140         const graphics::Animation *meleeAnimation;
141         const graphics::Animation *attackAnimation;
142         const graphics::Animation *spellAnimation;
143
144         graphics::AnimationRunner animation;
145
146         geometry::Vector<int> position;
147
148         graphics::Menu<const common::Spell *> spellMenu;
149         graphics::Menu<const common::Item *> ikariMenu;
150
151         AttackChoice attackChoice;
152
153         // TODO: vector does not seem to be a good choice
154         std::vector<const common::Spell *> spells;
155
156         int maxHealth, health;
157         int maxMana, mana;
158
159         Stats stats;
160
161         int level;
162         int ip;
163
164 };
165
166 }
167
168 #endif /* BATTLE_HERO_H_ */