]> git.localhorst.tv Git - l2e.git/blob - src/common/Hero.h
implemented "remove all" in equipment menu
[l2e.git] / src / common / Hero.h
1 /*
2  * Hero.h
3  *
4  *  Created on: Oct 7, 2012
5  *      Author: holy
6  */
7
8 #ifndef COMMON_HERO_H_
9 #define COMMON_HERO_H_
10
11 #include "fwd.h"
12 #include "Stats.h"
13 #include "../graphics/fwd.h"
14 #include "../map/Entity.h"
15
16 #include <vector>
17
18 namespace common {
19
20 class Hero {
21
22 public:
23         static const int TYPE_ID = 301;
24
25 public:
26         Hero();
27         ~Hero() { }
28
29 public:
30         const char *Name() const { return name; }
31
32         Uint16 MaxHealth() const { return maxHealth; }
33         Uint16 Health() const { return health; }
34         int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
35         void SubtractHealth(int amount);
36
37         Uint16 MaxMana() const { return maxMana; }
38         Uint16 Mana() const { return mana; }
39         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
40         bool CanUseMagic() const { return MaxMana() > 0; }
41
42         Uint8 MaxIP() const { return 255; }
43         Uint8 IP() const { return ip; }
44         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
45
46         Stats &GetStats() { return stats; }
47         const Stats &GetStats() const { return stats; }
48
49         Uint8 Level() const { return level; }
50         int Experience() const { return experience; }
51         int NextLevel() const;
52
53         Item *Weapon() { return weapon; }
54         Item *Armor() { return armor; }
55         Item *Shield() { return shield; }
56         Item *Helmet() { return helmet; }
57         Item *Ring() { return ring; }
58         Item *Jewel() { return jewel; }
59
60         const Item *Weapon() const { return weapon; }
61         const Item *Armor() const { return armor; }
62         const Item *Shield() const { return shield; }
63         const Item *Helmet() const { return helmet; }
64         const Item *Ring() const { return ring; }
65         const Item *Jewel() const { return jewel; }
66
67         bool HasWeapon() const { return weapon; }
68         bool HasArmor() const { return armor; }
69         bool HasShield() const { return shield; }
70         bool HasHelmet() const { return helmet; }
71         bool HasRing() const { return ring; }
72         bool HasJewel() const { return jewel; }
73
74         void RemoveWeapon() { weapon = 0; }
75         void RemoveArmor() { armor = 0; }
76         void RemoveShield() { shield = 0; }
77         void RemoveHelmet() { helmet = 0; }
78         void RemoveRing() { ring = 0; }
79         void RemoveJewel() { jewel = 0; }
80
81         std::vector<const Spell *> &Spells() { return spells; }
82         const std::vector<const Spell *> &Spells() const { return spells; }
83
84         graphics::Sprite *BattleSprite() { return battleSprite; }
85         const graphics::Sprite *BattleSprite() const { return battleSprite; }
86         graphics::Animation *MeleeAnimation() { return meleeAnimation; }
87         graphics::Animation *AttackAnimation() { return attackAnimation; }
88         graphics::Animation *SpellAnimation() { return spellAnimation; }
89
90         map::Entity &MapEntity() { return mapEntity; }
91         const map::Entity &MapEntity() const { return mapEntity; }
92
93         static void CreateTypeDescription();
94         static void Construct(void *);
95
96 // temporary setters
97 public:
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(Spell *s) { spells.push_back(s); }
106
107 private:
108         const char *name;
109
110         int maxHealth, health;
111         int maxMana, mana;
112         int ip;
113
114         Stats stats;
115
116         int level;
117         int experience;
118
119         int *levelLadder;
120         int numLevels;
121
122         Item *weapon;
123         Item *armor;
124         Item *shield;
125         Item *helmet;
126         Item *ring;
127         Item *jewel;
128
129         // TODO: vector does not seem to be a good choice
130         std::vector<const Spell *> spells;
131
132         graphics::Sprite *battleSprite;
133         graphics::Animation *meleeAnimation;
134         graphics::Animation *attackAnimation;
135         graphics::Animation *spellAnimation;
136
137         map::Entity mapEntity;
138
139 };
140
141 }
142
143 #endif /* COMMON_HERO_H_ */