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