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