]> git.localhorst.tv Git - l2e.git/blob - src/battle/Capsule.h
added capsule attack/animation handling
[l2e.git] / src / battle / Capsule.h
1 #ifndef BATTLE_CAPSULE_H_
2 #define BATTLE_CAPSULE_H_
3
4 #include "AttackChoice.h"
5 #include "../common/fwd.h"
6 #include "../common/Stats.h"
7 #include "../geometry/Vector.h"
8 #include "../graphics/Animation.h"
9 #include "../graphics/fwd.h"
10 #include "../graphics/Menu.h"
11
12 namespace battle {
13
14 class Capsule {
15
16 public:
17         Capsule();
18
19 public:
20         const char *Name() const { return name; }
21         Uint8 Level() const { return level; }
22         const graphics::Sprite *Sprite() const { return battleSprite; }
23
24         Uint16 MaxHealth() const { return maxHealth; }
25         Uint16 Health() const { return health; }
26         int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
27         void SubtractHealth(int amount);
28
29         Uint16 MaxMana() const { return maxMana; }
30         Uint16 Mana() const { return mana; }
31         int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
32         bool CanUseMagic() const { return MaxMana() > 0; }
33
34         common::Stats &GetStats() { return stats; }
35         const common::Stats &GetStats() const { return stats; }
36
37         graphics::AnimationRunner &GetAnimation() { return animation; }
38         const graphics::AnimationRunner &GetAnimation() const { return animation; }
39         void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
40
41         const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
42         const graphics::Animation *AttackAnimation() const { return attackAnimation; }
43         const graphics::Animation *SpellAnimation() const { return spellAnimation; }
44
45         geometry::Vector<int> &Position() { return position; }
46         const geometry::Vector<int> &Position() const { return position; }
47
48         AttackChoice &GetAttackChoice() { return attackChoice; }
49         const AttackChoice &GetAttackChoice() const { return attackChoice; }
50
51 // temporary setters
52 public:
53         void SetName(const char *n) { name = n; }
54         void SetHealth(int max, int cur) { maxHealth = max; health = cur; }
55         void SetMana(int max, int cur) { maxMana = max; mana = cur; }
56         void SetLevel(int l) { level = l; }
57         void SetBattleSprite(graphics::Sprite *s) { battleSprite = s; }
58         void SetMeleeAnimation(graphics::Animation *a) { meleeAnimation = a; }
59         void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; }
60         void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; }
61
62 private:
63         const char *name;
64
65         int maxHealth, health;
66         int maxMana, mana;
67
68         int level;
69
70         graphics::Sprite *battleSprite;
71         graphics::Animation *meleeAnimation;
72         graphics::Animation *attackAnimation;
73         graphics::Animation *spellAnimation;
74
75         graphics::AnimationRunner animation;
76         geometry::Vector<int> position;
77         AttackChoice attackChoice;
78         common::Stats stats;
79
80 };
81
82 }
83
84 #endif /* BATTLE_CAPSULE_H_ */