]> git.localhorst.tv Git - l2e.git/blob - src/common/Hero.h
removed stupid file headers that eclipse put in
[l2e.git] / src / common / Hero.h
1 #ifndef COMMON_HERO_H_
2 #define COMMON_HERO_H_
3
4 #include "fwd.h"
5 #include "Stats.h"
6 #include "../graphics/fwd.h"
7 #include "../map/Entity.h"
8
9 #include <vector>
10
11 namespace common {
12
13 class Hero {
14
15 public:
16         static const int TYPE_ID = 301;
17
18 public:
19         Hero();
20         ~Hero() { }
21
22 public:
23         enum EquipSlot {
24                 EQUIP_WEAPON,
25                 EQUIP_ARMOR,
26                 EQUIP_SHIELD,
27                 EQUIP_HELMET,
28                 EQUIP_RING,
29                 EQUIP_JEWEL,
30                 EQUIP_COUNT,
31         };
32
33         const char *Name() const { return name; }
34
35         Uint16 MaxHealth() const { return maxHealth; }
36         Uint16 Health() const { return health; }
37         int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
38         void SubtractHealth(int amount);
39
40         Uint16 MaxMana() const { return maxMana; }
41         Uint16 Mana() const { return mana; }
42         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
43         bool CanUseMagic() const { return MaxMana() > 0; }
44
45         Uint8 MaxIP() const { return 255; }
46         Uint8 IP() const { return ip; }
47         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
48
49         Stats &GetStats() { return stats; }
50         const Stats &GetStats() const { return stats; }
51
52         Uint8 Level() const { return level; }
53         int Experience() const { return experience; }
54         int NextLevel() const;
55
56         bool CanEquip(const Item &) const;
57         bool CanInvoke(const Spell &) const;
58
59         const Item *Equipment(EquipSlot i) const { return equipment[i]; }
60         bool Equipped(EquipSlot i) const { return equipment[i]; }
61         void RemoveEquipment(EquipSlot i) { equipment[i] = 0; }
62         void SetEquipment(EquipSlot i, const Item *item) { equipment[i] = item; }
63
64         std::vector<const Spell *> &Spells() { return spells; }
65         const std::vector<const Spell *> &Spells() const { return spells; }
66
67         graphics::Sprite *BattleSprite() { return battleSprite; }
68         const graphics::Sprite *BattleSprite() const { return battleSprite; }
69         graphics::Animation *MeleeAnimation() { return meleeAnimation; }
70         graphics::Animation *AttackAnimation() { return attackAnimation; }
71         graphics::Animation *SpellAnimation() { return spellAnimation; }
72
73         map::Entity &MapEntity() { return mapEntity; }
74         const map::Entity &MapEntity() const { return mapEntity; }
75
76         static void CreateTypeDescription();
77         static void Construct(void *);
78
79 // temporary setters
80 public:
81         void AddSpell(Spell *s) { spells.push_back(s); }
82
83 private:
84         const char *name;
85
86         int maxHealth, health;
87         int maxMana, mana;
88         int ip;
89
90         Stats stats;
91
92         int level;
93         int experience;
94
95         int *levelLadder;
96         int numLevels;
97
98         int useMask;
99
100         const Item *equipment[EQUIP_COUNT];
101
102         // TODO: vector does not seem to be a good choice
103         std::vector<const Spell *> spells;
104
105         graphics::Sprite *battleSprite;
106         graphics::Animation *meleeAnimation;
107         graphics::Animation *attackAnimation;
108         graphics::Animation *spellAnimation;
109
110         map::Entity mapEntity;
111
112 };
113
114 }
115
116 #endif /* COMMON_HERO_H_ */