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