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