]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
apply damage indicated by attack selection
[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         void SubtractHealth(int amount);
42
43         Uint16 MaxMana() const { return maxMana; }
44         Uint16 Mana() const { return mana; }
45         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
46         bool CanUseMagic() const { return MaxMana() > 0; }
47
48         Uint8 MaxIP() const { return 255; }
49         Uint8 IP() const { return ip; }
50         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
51
52         Uint16 Attack() const { return attack; }
53         Uint16 Defense() const { return defense; }
54         Uint16 Agility() const { return agility; }
55         Uint16 Intelligence() const { return intelligence; }
56         Uint16 Gut() const { return gut; }
57         Uint16 MagicResistance() const { return magicResistance; }
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::Animation *MeleeAnimation() { return meleeAnimation; }
81         const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
82         graphics::Animation *AttackAnimation() { return attackAnimation; }
83         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
84         graphics::Animation *SpellAnimation() { return spellAnimation; }
85         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
86
87 // temporary setters until loader is implemented
88 public:
89         void SetName(const char *n) { name = n; }
90         void SetLevel(Uint8 l) { level = l; }
91         void SetSprite(graphics::Sprite *s) { sprite = s; }
92
93         void SetMaxHealth(Uint16 h) { maxHealth = h; }
94         void SetHealth(Uint16 h) { health = h; }
95         void SetMaxMana(Uint16 m) { maxMana = m; }
96         void SetMana(Uint16 m) { mana = m; }
97         void SetIP(Uint8 i) { ip = i; }
98
99         void SetWeapon(common::Item *i) { weapon = i; }
100         void SetArmor(common::Item *i) { armor = i; }
101         void SetShield(common::Item *i) { shield = i; }
102         void SetHelmet(common::Item *i) { helmet = i; }
103         void SetRing(common::Item *i) { ring = i; }
104         void SetJewel(common::Item *i) { jewel = i; }
105
106         void AddSpell(const common::Spell *s) { spells.push_back(s); }
107
108         void SetMeleeAnimation(graphics::Animation *a) { meleeAnimation = a; }
109         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
110         void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; }
111
112 private:
113         const char *name;
114         graphics::Sprite *sprite;
115
116         common::Item *weapon;
117         common::Item *armor;
118         common::Item *shield;
119         common::Item *helmet;
120         common::Item *ring;
121         common::Item *jewel;
122
123         graphics::Animation *meleeAnimation;
124         graphics::Animation *attackAnimation;
125         graphics::Animation *spellAnimation;
126
127         // TODO: vector does not seem to be a good choice
128         std::vector<const common::Spell *> spells;
129
130         Uint16 maxHealth, health;
131         Uint16 maxMana, mana;
132
133         Uint16 attack;
134         Uint16 defense;
135         Uint16 agility;
136         Uint16 intelligence;
137         Uint16 gut;
138         Uint16 magicResistance;
139
140         Uint8 level;
141         Uint8 ip;
142
143 };
144
145 }
146
147 #endif /* BATTLE_HERO_H_ */