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