]> git.localhorst.tv Git - l2e.git/blob - src/common/Hero.h
b12e8f5b50c8e3ae719814d42c638f08ed057c0d
[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
51         Item *Weapon() { return weapon; }
52         Item *Armor() { return armor; }
53         Item *Shield() { return shield; }
54         Item *Helmet() { return helmet; }
55         Item *Ring() { return ring; }
56         Item *Jewel() { return jewel; }
57
58         const Item *Weapon() const { return weapon; }
59         const Item *Armor() const { return armor; }
60         const Item *Shield() const { return shield; }
61         const Item *Helmet() const { return helmet; }
62         const Item *Ring() const { return ring; }
63         const Item *Jewel() const { return jewel; }
64
65         bool HasWeapon() const { return weapon; }
66         bool HasArmor() const { return armor; }
67         bool HasShield() const { return shield; }
68         bool HasHelmet() const { return helmet; }
69         bool HasRing() const { return ring; }
70         bool HasJewel() const { return jewel; }
71
72         const std::vector<const Spell *> &Spells() const { return spells; }
73
74         graphics::Sprite *BattleSprite() { return battleSprite; }
75         const graphics::Sprite *BattleSprite() const { return battleSprite; }
76         graphics::Animation *MeleeAnimation() { return meleeAnimation; }
77         graphics::Animation *AttackAnimation() { return attackAnimation; }
78         graphics::Animation *SpellAnimation() { return spellAnimation; }
79
80         map::Entity &MapEntity() { return mapEntity; }
81         const map::Entity &MapEntity() const { return mapEntity; }
82
83         static void CreateTypeDescription();
84         static void Construct(void *);
85
86 // temporary setters
87 public:
88         void SetWeapon(common::Item *i) { weapon = i; }
89         void SetArmor(common::Item *i) { armor = i; }
90         void SetShield(common::Item *i) { shield = i; }
91         void SetHelmet(common::Item *i) { helmet = i; }
92         void SetRing(common::Item *i) { ring = i; }
93         void SetJewel(common::Item *i) { jewel = i; }
94
95         void AddSpell(Spell *s) { spells.push_back(s); }
96
97 private:
98         const char *name;
99
100         int maxHealth, health;
101         int maxMana, mana;
102         int ip;
103
104         Stats stats;
105
106         int level;
107
108         Item *weapon;
109         Item *armor;
110         Item *shield;
111         Item *helmet;
112         Item *ring;
113         Item *jewel;
114
115         // TODO: vector does not seem to be a good choice
116         std::vector<const Spell *> spells;
117
118         graphics::Sprite *battleSprite;
119         graphics::Animation *meleeAnimation;
120         graphics::Animation *attackAnimation;
121         graphics::Animation *spellAnimation;
122
123         map::Entity mapEntity;
124
125 };
126
127 }
128
129 #endif /* COMMON_HERO_H_ */