]> git.localhorst.tv Git - l2e.git/blob - src/common/Hero.h
store complete entity in hero
[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         Hero();
24         ~Hero() { }
25
26 public:
27         const char *Name() const { return name; }
28
29         Uint16 MaxHealth() const { return maxHealth; }
30         Uint16 Health() const { return health; }
31         int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
32         void SubtractHealth(int amount);
33
34         Uint16 MaxMana() const { return maxMana; }
35         Uint16 Mana() const { return mana; }
36         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
37         bool CanUseMagic() const { return MaxMana() > 0; }
38
39         Uint8 MaxIP() const { return 255; }
40         Uint8 IP() const { return ip; }
41         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
42
43         Stats &GetStats() { return stats; }
44         const Stats &GetStats() const { return stats; }
45
46         Uint8 Level() const { return level; }
47
48         Item *Weapon() { return weapon; }
49         Item *Armor() { return armor; }
50         Item *Shield() { return shield; }
51         Item *Helmet() { return helmet; }
52         Item *Ring() { return ring; }
53         Item *Jewel() { return jewel; }
54
55         const Item *Weapon() const { return weapon; }
56         const Item *Armor() const { return armor; }
57         const Item *Shield() const { return shield; }
58         const Item *Helmet() const { return helmet; }
59         const Item *Ring() const { return ring; }
60         const 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         const std::vector<const Spell *> &Spells() const { return spells; }
70
71         graphics::Sprite *BattleSprite() { return battleSprite; }
72         graphics::Animation *MeleeAnimation() { return meleeAnimation; }
73         graphics::Animation *AttackAnimation() { return attackAnimation; }
74         graphics::Animation *SpellAnimation() { return spellAnimation; }
75
76         map::Entity &MapEntity() { return mapEntity; }
77         const map::Entity &MapEntity() const { return mapEntity; }
78
79         static void CreateTypeDescription();
80         static void Construct(void *);
81
82 // temporary setters
83 public:
84         void SetWeapon(common::Item *i) { weapon = i; }
85         void SetArmor(common::Item *i) { armor = i; }
86         void SetShield(common::Item *i) { shield = i; }
87         void SetHelmet(common::Item *i) { helmet = i; }
88         void SetRing(common::Item *i) { ring = i; }
89         void SetJewel(common::Item *i) { jewel = i; }
90
91         void AddSpell(Spell *s) { spells.push_back(s); }
92
93 private:
94         const char *name;
95
96         int maxHealth, health;
97         int maxMana, mana;
98         int ip;
99
100         Stats stats;
101
102         int level;
103
104         Item *weapon;
105         Item *armor;
106         Item *shield;
107         Item *helmet;
108         Item *ring;
109         Item *jewel;
110
111         // TODO: vector does not seem to be a good choice
112         std::vector<const Spell *> spells;
113
114         graphics::Sprite *battleSprite;
115         graphics::Animation *meleeAnimation;
116         graphics::Animation *attackAnimation;
117         graphics::Animation *spellAnimation;
118
119         map::Entity mapEntity;
120
121 };
122
123 }
124
125 #endif /* COMMON_HERO_H_ */