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