]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
added sword attack 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 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         common::Item *Weapon() { return weapon; }
59         common::Item *Armor() { return armor; }
60         common::Item *Shield() { return shield; }
61         common::Item *Helmet() { return helmet; }
62         common::Item *Ring() { return ring; }
63         common::Item *Jewel() { return jewel; }
64
65         const common::Item *Weapon() const { return weapon; }
66         const common::Item *Armor() const { return armor; }
67         const common::Item *Shield() const { return shield; }
68         const common::Item *Helmet() const { return helmet; }
69         const common::Item *Ring() const { return ring; }
70         const common::Item *Jewel() const { return jewel; }
71
72         bool HasWeapon() const { return weapon; }
73         bool HasArmor() const { return armor; }
74         bool HasShield() const { return shield; }
75         bool HasHelmet() const { return helmet; }
76         bool HasRing() const { return ring; }
77         bool HasJewel() const { return jewel; }
78
79         graphics::Animation *MeleeAnimation() { return meleeAnimation; }
80         const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
81         graphics::Animation *AttackAnimation() { return attackAnimation; }
82         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
83         graphics::Animation *SpellAnimation() { return spellAnimation; }
84         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
85
86 // temporary setters until loader is implemented
87 public:
88         void SetName(const char *n) { name = n; }
89         void SetLevel(Uint8 l) { level = l; }
90         void SetSprite(graphics::Sprite *s) { sprite = s; }
91
92         void SetMaxHealth(Uint16 h) { maxHealth = h; }
93         void SetHealth(Uint16 h) { health = h; }
94         void SetMaxMana(Uint16 m) { maxMana = m; }
95         void SetMana(Uint16 m) { mana = m; }
96         void SetIP(Uint8 i) { ip = i; }
97
98         void SetWeapon(common::Item *i) { weapon = i; }
99         void SetArmor(common::Item *i) { armor = i; }
100         void SetShield(common::Item *i) { shield = i; }
101         void SetHelmet(common::Item *i) { helmet = i; }
102         void SetRing(common::Item *i) { ring = i; }
103         void SetJewel(common::Item *i) { jewel = i; }
104
105         void AddSpell(const common::Spell *s) { spells.push_back(s); }
106
107         void SetMeleeAnimation(graphics::Animation *a) { meleeAnimation = a; }
108         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
109         void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; }
110
111 private:
112         const char *name;
113         graphics::Sprite *sprite;
114
115         common::Item *weapon;
116         common::Item *armor;
117         common::Item *shield;
118         common::Item *helmet;
119         common::Item *ring;
120         common::Item *jewel;
121
122         graphics::Animation *meleeAnimation;
123         graphics::Animation *attackAnimation;
124         graphics::Animation *spellAnimation;
125
126         // TODO: vector does not seem to be a good choice
127         std::vector<const common::Spell *> spells;
128
129         Uint16 maxHealth, health;
130         Uint16 maxMana, mana;
131
132         Uint16 attack;
133         Uint16 defense;
134         Uint16 agility;
135         Uint16 intelligence;
136         Uint16 gut;
137         Uint16 magicResistance;
138
139         Uint8 level;
140         Uint8 ip;
141
142 };
143
144 }
145
146 #endif /* BATTLE_HERO_H_ */