]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
added spells
[l2e.git] / src / battle / Hero.h
1 /*
2  * Hero.h
3  *
4  *  Created on: Aug 6, 2012
5  *      Author: holy
6  */
7
8 #ifndef BATTLE_HERO_H_
9 #define BATTLE_HERO_H_
10
11 #include <vector>
12 #include <SDL.h>
13
14 namespace common { class Spell; }
15 namespace graphics { class Sprite; }
16
17 namespace battle {
18
19 class Hero {
20
21 public:
22         Hero();
23         ~Hero();
24
25 public:
26         const char *Name() const { return name; }
27         Uint8 Level() const { return level; }
28         const graphics::Sprite *Sprite() const { return sprite; }
29
30         const std::vector<const common::Spell *> &Spells() const { return spells; }
31
32         Uint16 MaxHealth() const { return maxHealth; }
33         Uint16 Health() const { return health; }
34         int RelativeHealth(int max) const { return health * max / maxHealth; }
35
36         Uint16 MaxMana() const { return maxMana; }
37         Uint16 Mana() const { return mana; }
38         int RelativeMana(int max) const { return maxMana == 0 ? 0 : mana * max / maxMana; }
39         bool CanUseMagic() const { return maxMana > 0; }
40
41         Uint8 IP() const { return ip; }
42         int RelativeIP(int max) const { return ip * max / 255; }
43
44         Uint16 Attack() const { return attack; }
45         Uint16 Defense() const { return defense; }
46         Uint16 Agility() const { return agility; }
47         Uint16 Intelligence() const { return intelligence; }
48         Uint16 Gut() const { return gut; }
49         Uint16 MagicResistance() const { return magicResistance; }
50
51 // temporary setters until loader is implemented
52 public:
53         void SetName(const char *n) { name = n; }
54         void SetLevel(Uint8 l) { level = l; }
55         void SetSprite(graphics::Sprite *s) { sprite = s; }
56
57         void SetMaxHealth(Uint16 h) { maxHealth = h; }
58         void SetHealth(Uint16 h) { health = h; }
59         void SetMaxMana(Uint16 m) { maxMana = m; }
60         void SetMana(Uint16 m) { mana = m; }
61         void SetIP(Uint8 i) { ip = i; }
62
63         void AddSpell(const common::Spell *s) { spells.push_back(s); }
64
65 private:
66         const char *name;
67         graphics::Sprite *sprite;
68
69         // TODO: vector does not seem to be a good choice
70         std::vector<const common::Spell *> spells;
71         // TODO: equipment list
72
73         Uint16 maxHealth, health;
74         Uint16 maxMana, mana;
75
76         Uint16 attack;
77         Uint16 defense;
78         Uint16 agility;
79         Uint16 intelligence;
80         Uint16 gut;
81         Uint16 magicResistance;
82
83         Uint8 level;
84         Uint8 ip;
85
86 };
87
88 }
89
90 #endif /* BATTLE_HERO_H_ */