]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
added type description of Hero
[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 "AttackChoice.h"
12 #include "Stats.h"
13 #include "../geometry/Vector.h"
14 #include "../graphics/Animation.h"
15 #include "../graphics/Menu.h"
16
17 #include <vector>
18 #include <SDL.h>
19
20 namespace common {
21         class Item;
22         class Spell;
23 }
24 namespace graphics {
25         class Sprite;
26 }
27
28 namespace battle {
29
30 class Resources;
31
32 class Hero {
33
34 public:
35         Hero();
36         ~Hero();
37
38 public:
39         const char *Name() const { return name; }
40         Uint8 Level() const { return level; }
41         const graphics::Sprite *Sprite() const { return sprite; }
42
43         const std::vector<const common::Spell *> &Spells() const { return spells; }
44
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);
49
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; }
54
55         Uint8 MaxIP() const { return 255; }
56         Uint8 IP() const { return ip; }
57         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
58
59         Stats &GetStats() { return stats; }
60         const Stats &GetStats() const { return stats; }
61
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; }
68
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; }
75
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; }
82
83         graphics::AnimationRunner &GetAnimation() { return animation; }
84         const graphics::AnimationRunner &GetAnimation() const { return animation; }
85         void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
86
87         const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
88         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
89         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
90
91         geometry::Vector<int> &Position() { return position; }
92         const geometry::Vector<int> &Position() const { return position; }
93
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; }
98
99         AttackChoice &GetAttackChoice() { return attackChoice; }
100         const AttackChoice &GetAttackChoice() const { return attackChoice; }
101
102 public:
103         void UpdateSpellMenu();
104         void UpdateIkariMenu(const Resources *);
105
106 // temporary setters until loader is implemented
107 public:
108         void SetName(const char *n) { name = n; }
109         void SetLevel(Uint8 l) { level = l; }
110         void SetSprite(graphics::Sprite *s) { sprite = s; }
111
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; }
117
118         void SetStats(const Stats &s) { stats = s; }
119
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; }
126
127         void AddSpell(const common::Spell *s) { spells.push_back(s); }
128
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; }
132
133         static void CreateTypeDescription();
134
135 private:
136         const char *name;
137         graphics::Sprite *sprite;
138
139         common::Item *weapon;
140         common::Item *armor;
141         common::Item *shield;
142         common::Item *helmet;
143         common::Item *ring;
144         common::Item *jewel;
145
146         const graphics::Animation *meleeAnimation;
147         const graphics::Animation *attackAnimation;
148         const graphics::Animation *spellAnimation;
149
150         graphics::AnimationRunner animation;
151
152         geometry::Vector<int> position;
153
154         graphics::Menu<const common::Spell *> spellMenu;
155         graphics::Menu<const common::Item *> ikariMenu;
156
157         AttackChoice attackChoice;
158
159         // TODO: vector does not seem to be a good choice
160         std::vector<const common::Spell *> spells;
161
162         int maxHealth, health;
163         int maxMana, mana;
164
165         Stats stats;
166
167         int level;
168         int ip;
169
170 };
171
172 }
173
174 #endif /* BATTLE_HERO_H_ */