]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.h
5e86f88dae783da4f8dbaf47d1666e32568fb82c
[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 "fwd.h"
12 #include "AttackChoice.h"
13 #include "../common/fwd.h"
14 #include "../common/Hero.h"
15 #include "../common/Stats.h"
16 #include "../geometry/Vector.h"
17 #include "../graphics/Animation.h"
18 #include "../graphics/fwd.h"
19 #include "../graphics/Menu.h"
20
21 #include <vector>
22 #include <SDL.h>
23
24 namespace battle {
25
26 class Hero {
27
28 public:
29         Hero();
30         Hero(common::Hero &);
31         ~Hero();
32
33 public:
34         const char *Name() const { return master->Name(); }
35         Uint8 Level() const { return master->Level(); }
36         const graphics::Sprite *Sprite() const { return master->BattleSprite(); }
37
38         const std::vector<const common::Spell *> &Spells() const { return master->Spells(); }
39
40         Uint16 MaxHealth() const { return master->MaxHealth(); }
41         Uint16 Health() const { return master->Health(); }
42         int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
43         void SubtractHealth(int amount) { master->SubtractHealth(amount); }
44
45         Uint16 MaxMana() const { return master->MaxMana(); }
46         Uint16 Mana() const { return master->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 master->MaxIP(); }
51         Uint8 IP() const { return master->IP(); }
52         int RelativeIP(int max) const { return IP() * max / MaxIP(); }
53
54         common::Stats &GetStats() { return stats; }
55         const common::Stats &GetStats() const { return stats; }
56
57         const common::Item *Weapon() const { return master->Equipment(common::Hero::EQUIP_WEAPON); }
58         const common::Item *Armor() const { return master->Equipment(common::Hero::EQUIP_ARMOR); }
59         const common::Item *Shield() const { return master->Equipment(common::Hero::EQUIP_SHIELD); }
60         const common::Item *Helmet() const { return master->Equipment(common::Hero::EQUIP_HELMET); }
61         const common::Item *Ring() const { return master->Equipment(common::Hero::EQUIP_RING); }
62         const common::Item *Jewel() const { return master->Equipment(common::Hero::EQUIP_JEWEL); }
63
64         bool HasWeapon() const { return master->Equipped(common::Hero::EQUIP_WEAPON); }
65         bool HasArmor() const { return master->Equipped(common::Hero::EQUIP_ARMOR); }
66         bool HasShield() const { return master->Equipped(common::Hero::EQUIP_SHIELD); }
67         bool HasHelmet() const { return master->Equipped(common::Hero::EQUIP_HELMET); }
68         bool HasRing() const { return master->Equipped(common::Hero::EQUIP_RING); }
69         bool HasJewel() const { return master->Equipped(common::Hero::EQUIP_JEWEL); }
70
71         graphics::AnimationRunner &GetAnimation() { return animation; }
72         const graphics::AnimationRunner &GetAnimation() const { return animation; }
73         void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
74
75         const graphics::Animation *MeleeAnimation() const { return master->MeleeAnimation(); }
76         const graphics::Animation *AttackAnimation() const { return master->AttackAnimation(); }
77         const graphics::Animation *SpellAnimation() const { return master->SpellAnimation(); }
78
79         geometry::Vector<int> &Position() { return position; }
80         const geometry::Vector<int> &Position() const { return position; }
81
82         graphics::Menu<const common::Spell *> &SpellMenu() { return spellMenu; }
83         const graphics::Menu<const common::Spell *> &SpellMenu() const { return spellMenu; }
84         graphics::Menu<const common::Item *> &IkariMenu() { return ikariMenu; }
85         const graphics::Menu<const common::Item *> &IkariMenu() const { return ikariMenu; }
86
87         AttackChoice &GetAttackChoice() { return attackChoice; }
88         const AttackChoice &GetAttackChoice() const { return attackChoice; }
89
90 public:
91         void UpdateSpellMenu();
92         void UpdateIkariMenu(const Resources *);
93
94 private:
95         common::Hero *master;
96
97         graphics::AnimationRunner animation;
98
99         geometry::Vector<int> position;
100
101         graphics::Menu<const common::Spell *> spellMenu;
102         graphics::Menu<const common::Item *> ikariMenu;
103
104         AttackChoice attackChoice;
105
106         common::Stats stats;
107
108 };
109
110 }
111
112 #endif /* BATTLE_HERO_H_ */