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