]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
added simple damage calculation formula
[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 "Stats.h"
12
13 #include <vector>
14 #include <SDL.h>
15
16 namespace common {
17         class Item;
18         class Spell;
19 }
20 namespace graphics {
21         class Animation;
22         class Sprite;
23 }
24
25 namespace battle {
26
27 class Hero {
28
29 public:
30         Hero();
31         ~Hero();
32
33 public:
34         const char *Name() const { return name; }
35         Uint8 Level() const { return level; }
36         const graphics::Sprite *Sprite() const { return sprite; }
37
38         const std::vector<const common::Spell *> &Spells() const { return spells; }
39
40         Uint16 MaxHealth() const { return maxHealth; }
41         Uint16 Health() const { return health; }
42         int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
43         void SubtractHealth(int amount);
44
45         Uint16 MaxMana() const { return maxMana; }
46         Uint16 Mana() const { return mana; }
47         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
48         bool CanUseMagic() const { return MaxMana() > 0; }
49
50         Uint8 MaxIP() const { return 255; }
51         Uint8 IP() const { return ip; }
52         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
53
54         Stats &GetStats() { return stats; }
55         const Stats &GetStats() const { return stats; }
56
57         common::Item *Weapon() { return weapon; }
58         common::Item *Armor() { return armor; }
59         common::Item *Shield() { return shield; }
60         common::Item *Helmet() { return helmet; }
61         common::Item *Ring() { return ring; }
62         common::Item *Jewel() { return jewel; }
63
64         const common::Item *Weapon() const { return weapon; }
65         const common::Item *Armor() const { return armor; }
66         const common::Item *Shield() const { return shield; }
67         const common::Item *Helmet() const { return helmet; }
68         const common::Item *Ring() const { return ring; }
69         const common::Item *Jewel() const { return jewel; }
70
71         bool HasWeapon() const { return weapon; }
72         bool HasArmor() const { return armor; }
73         bool HasShield() const { return shield; }
74         bool HasHelmet() const { return helmet; }
75         bool HasRing() const { return ring; }
76         bool HasJewel() const { return jewel; }
77
78         graphics::Animation *MeleeAnimation() { return meleeAnimation; }
79         const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
80         graphics::Animation *AttackAnimation() { return attackAnimation; }
81         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
82         graphics::Animation *SpellAnimation() { return spellAnimation; }
83         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
84
85 // temporary setters until loader is implemented
86 public:
87         void SetName(const char *n) { name = n; }
88         void SetLevel(Uint8 l) { level = l; }
89         void SetSprite(graphics::Sprite *s) { sprite = s; }
90
91         void SetMaxHealth(Uint16 h) { maxHealth = h; }
92         void SetHealth(Uint16 h) { health = h; }
93         void SetMaxMana(Uint16 m) { maxMana = m; }
94         void SetMana(Uint16 m) { mana = m; }
95         void SetIP(Uint8 i) { ip = i; }
96
97         void SetStats(const Stats &s) { stats = s; }
98
99         void SetWeapon(common::Item *i) { weapon = i; }
100         void SetArmor(common::Item *i) { armor = i; }
101         void SetShield(common::Item *i) { shield = i; }
102         void SetHelmet(common::Item *i) { helmet = i; }
103         void SetRing(common::Item *i) { ring = i; }
104         void SetJewel(common::Item *i) { jewel = i; }
105
106         void AddSpell(const common::Spell *s) { spells.push_back(s); }
107
108         void SetMeleeAnimation(graphics::Animation *a) { meleeAnimation = a; }
109         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
110         void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; }
111
112 private:
113         const char *name;
114         graphics::Sprite *sprite;
115
116         common::Item *weapon;
117         common::Item *armor;
118         common::Item *shield;
119         common::Item *helmet;
120         common::Item *ring;
121         common::Item *jewel;
122
123         graphics::Animation *meleeAnimation;
124         graphics::Animation *attackAnimation;
125         graphics::Animation *spellAnimation;
126
127         // TODO: vector does not seem to be a good choice
128         std::vector<const common::Spell *> spells;
129
130         Uint16 maxHealth, health;
131         Uint16 maxMana, mana;
132
133         Stats stats;
134
135         Uint8 level;
136         Uint8 ip;
137
138 };
139
140 }
141
142 #endif /* BATTLE_HERO_H_ */