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