]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
e200838487a177cef24e2ea0b200d1a35a99867f
[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 <vector>
12 #include <SDL.h>
13
14 namespace common {
15         class Item;
16         class Spell;
17 }
18 namespace graphics {
19         class Animation;
20         class Sprite;
21 }
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
42         Uint16 MaxMana() const { return maxMana; }
43         Uint16 Mana() const { return mana; }
44         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
45         bool CanUseMagic() const { return MaxMana() > 0; }
46
47         Uint8 MaxIP() const { return 255; }
48         Uint8 IP() const { return ip; }
49         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
50
51         Uint16 Attack() const { return attack; }
52         Uint16 Defense() const { return defense; }
53         Uint16 Agility() const { return agility; }
54         Uint16 Intelligence() const { return intelligence; }
55         Uint16 Gut() const { return gut; }
56         Uint16 MagicResistance() const { return magicResistance; }
57
58         const common::Item *Weapon() const { return weapon; }
59         const common::Item *Armor() const { return armor; }
60         const common::Item *Shield() const { return shield; }
61         const common::Item *Helmet() const { return helmet; }
62         const common::Item *Ring() const { return ring; }
63         const common::Item *Jewel() const { return jewel; }
64
65         bool HasWeapon() const { return weapon; }
66         bool HasArmor() const { return armor; }
67         bool HasShield() const { return shield; }
68         bool HasHelmet() const { return helmet; }
69         bool HasRing() const { return ring; }
70         bool HasJewel() const { return jewel; }
71
72         graphics::Animation *MeleeAnimation() { return meleeAnimation; }
73         const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
74         graphics::Animation *AttackAnimation() { return attackAnimation; }
75         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
76         graphics::Animation *SpellAnimation() { return spellAnimation; }
77         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
78
79 // temporary setters until loader is implemented
80 public:
81         void SetName(const char *n) { name = n; }
82         void SetLevel(Uint8 l) { level = l; }
83         void SetSprite(graphics::Sprite *s) { sprite = s; }
84
85         void SetMaxHealth(Uint16 h) { maxHealth = h; }
86         void SetHealth(Uint16 h) { health = h; }
87         void SetMaxMana(Uint16 m) { maxMana = m; }
88         void SetMana(Uint16 m) { mana = m; }
89         void SetIP(Uint8 i) { ip = i; }
90
91         void SetWeapon(const common::Item *i) { weapon = i; }
92         void SetArmor(const common::Item *i) { armor = i; }
93         void SetShield(const common::Item *i) { shield = i; }
94         void SetHelmet(const common::Item *i) { helmet = i; }
95         void SetRing(const common::Item *i) { ring = i; }
96         void SetJewel(const common::Item *i) { jewel = i; }
97
98         void AddSpell(const common::Spell *s) { spells.push_back(s); }
99
100         void SetMeleeAnimation(graphics::Animation *a) { meleeAnimation = a; }
101         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
102         void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; }
103
104 private:
105         const char *name;
106         graphics::Sprite *sprite;
107
108         const common::Item *weapon;
109         const common::Item *armor;
110         const common::Item *shield;
111         const common::Item *helmet;
112         const common::Item *ring;
113         const common::Item *jewel;
114
115         graphics::Animation *meleeAnimation;
116         graphics::Animation *attackAnimation;
117         graphics::Animation *spellAnimation;
118
119         // TODO: vector does not seem to be a good choice
120         std::vector<const common::Spell *> spells;
121
122         Uint16 maxHealth, health;
123         Uint16 maxMana, mana;
124
125         Uint16 attack;
126         Uint16 defense;
127         Uint16 agility;
128         Uint16 intelligence;
129         Uint16 gut;
130         Uint16 magicResistance;
131
132         Uint8 level;
133         Uint8 ip;
134
135 };
136
137 }
138
139 #endif /* BATTLE_HERO_H_ */