]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
moved spell and ikari menu initialization to 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 "../graphics/Animation.h"
14 #include "../graphics/Menu.h"
15
16 #include <vector>
17 #include <SDL.h>
18
19 namespace common {
20         class Item;
21         class Spell;
22 }
23 namespace graphics {
24         class Sprite;
25 }
26
27 namespace battle {
28
29 class Resources;
30
31 class Hero {
32
33 public:
34         Hero();
35         ~Hero();
36
37 public:
38         const char *Name() const { return name; }
39         Uint8 Level() const { return level; }
40         const graphics::Sprite *Sprite() const { return sprite; }
41
42         const std::vector<const common::Spell *> &Spells() const { return spells; }
43
44         Uint16 MaxHealth() const { return maxHealth; }
45         Uint16 Health() const { return health; }
46         int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
47         void SubtractHealth(int amount);
48
49         Uint16 MaxMana() const { return maxMana; }
50         Uint16 Mana() const { return mana; }
51         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
52         bool CanUseMagic() const { return MaxMana() > 0; }
53
54         Uint8 MaxIP() const { return 255; }
55         Uint8 IP() const { return ip; }
56         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
57
58         Stats &GetStats() { return stats; }
59         const Stats &GetStats() const { return stats; }
60
61         common::Item *Weapon() { return weapon; }
62         common::Item *Armor() { return armor; }
63         common::Item *Shield() { return shield; }
64         common::Item *Helmet() { return helmet; }
65         common::Item *Ring() { return ring; }
66         common::Item *Jewel() { return jewel; }
67
68         const common::Item *Weapon() const { return weapon; }
69         const common::Item *Armor() const { return armor; }
70         const common::Item *Shield() const { return shield; }
71         const common::Item *Helmet() const { return helmet; }
72         const common::Item *Ring() const { return ring; }
73         const common::Item *Jewel() const { return jewel; }
74
75         bool HasWeapon() const { return weapon; }
76         bool HasArmor() const { return armor; }
77         bool HasShield() const { return shield; }
78         bool HasHelmet() const { return helmet; }
79         bool HasRing() const { return ring; }
80         bool HasJewel() const { return jewel; }
81
82         graphics::AnimationRunner &GetAnimation() { return animation; }
83         const graphics::AnimationRunner &GetAnimation() const { return animation; }
84         void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
85
86         const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
87         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
88         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
89
90         graphics::Menu<const common::Spell *> &SpellMenu() { return spellMenu; }
91         const graphics::Menu<const common::Spell *> &SpellMenu() const { return spellMenu; }
92         graphics::Menu<const common::Item *> &IkariMenu() { return ikariMenu; }
93         const graphics::Menu<const common::Item *> &IkariMenu() const { return ikariMenu; }
94
95         AttackChoice &GetAttackChoice() { return attackChoice; }
96         const AttackChoice &GetAttackChoice() const { return attackChoice; }
97
98 public:
99         void UpdateSpellMenu();
100         void UpdateIkariMenu(const Resources *);
101
102 // temporary setters until loader is implemented
103 public:
104         void SetName(const char *n) { name = n; }
105         void SetLevel(Uint8 l) { level = l; }
106         void SetSprite(graphics::Sprite *s) { sprite = s; }
107
108         void SetMaxHealth(Uint16 h) { maxHealth = h; }
109         void SetHealth(Uint16 h) { health = h; }
110         void SetMaxMana(Uint16 m) { maxMana = m; }
111         void SetMana(Uint16 m) { mana = m; }
112         void SetIP(Uint8 i) { ip = i; }
113
114         void SetStats(const Stats &s) { stats = s; }
115
116         void SetWeapon(common::Item *i) { weapon = i; }
117         void SetArmor(common::Item *i) { armor = i; }
118         void SetShield(common::Item *i) { shield = i; }
119         void SetHelmet(common::Item *i) { helmet = i; }
120         void SetRing(common::Item *i) { ring = i; }
121         void SetJewel(common::Item *i) { jewel = i; }
122
123         void AddSpell(const common::Spell *s) { spells.push_back(s); }
124
125         void SetMeleeAnimation(const graphics::Animation *a) { meleeAnimation = a; }
126         void SetAttackAnimation(const graphics::Animation *a) { attackAnimation = a; }
127         void SetSpellAnimation(const graphics::Animation *a) { spellAnimation = a; }
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         graphics::Menu<const common::Spell *> spellMenu;
147         graphics::Menu<const common::Item *> ikariMenu;
148
149         AttackChoice attackChoice;
150
151         // TODO: vector does not seem to be a good choice
152         std::vector<const common::Spell *> spells;
153
154         Uint16 maxHealth, health;
155         Uint16 maxMana, mana;
156
157         Stats stats;
158
159         Uint8 level;
160         Uint8 ip;
161
162 };
163
164 }
165
166 #endif /* BATTLE_HERO_H_ */