]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
added complex attack and spell animations
[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 *AttackAnimation() { return attackAnimation; }
73         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
74         graphics::Animation *SpellAnimation() { return spellAnimation; }
75         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
76
77 // temporary setters until loader is implemented
78 public:
79         void SetName(const char *n) { name = n; }
80         void SetLevel(Uint8 l) { level = l; }
81         void SetSprite(graphics::Sprite *s) { sprite = s; }
82
83         void SetMaxHealth(Uint16 h) { maxHealth = h; }
84         void SetHealth(Uint16 h) { health = h; }
85         void SetMaxMana(Uint16 m) { maxMana = m; }
86         void SetMana(Uint16 m) { mana = m; }
87         void SetIP(Uint8 i) { ip = i; }
88
89         void SetWeapon(const common::Item *i) { weapon = i; }
90         void SetArmor(const common::Item *i) { armor = i; }
91         void SetShield(const common::Item *i) { shield = i; }
92         void SetHelmet(const common::Item *i) { helmet = i; }
93         void SetRing(const common::Item *i) { ring = i; }
94         void SetJewel(const common::Item *i) { jewel = i; }
95
96         void AddSpell(const common::Spell *s) { spells.push_back(s); }
97
98         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
99         void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; }
100
101 private:
102         const char *name;
103         graphics::Sprite *sprite;
104
105         const common::Item *weapon;
106         const common::Item *armor;
107         const common::Item *shield;
108         const common::Item *helmet;
109         const common::Item *ring;
110         const common::Item *jewel;
111
112         graphics::Animation *attackAnimation;
113         graphics::Animation *spellAnimation;
114
115         // TODO: vector does not seem to be a good choice
116         std::vector<const common::Spell *> spells;
117
118         Uint16 maxHealth, health;
119         Uint16 maxMana, mana;
120
121         Uint16 attack;
122         Uint16 defense;
123         Uint16 agility;
124         Uint16 intelligence;
125         Uint16 gut;
126         Uint16 magicResistance;
127
128         Uint8 level;
129         Uint8 ip;
130
131 };
132
133 }
134
135 #endif /* BATTLE_HERO_H_ */