16 #include "../map/Entity.h"
25 static const int TYPE_ID = 301;
55 const char *Name() const { return name; }
57 Uint16 MaxHealth() const { return maxHealth; }
58 Uint16 Health() const { return health; }
59 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
60 void SubtractHealth(int amount);
62 Uint16 MaxMana() const { return maxMana; }
63 Uint16 Mana() const { return mana; }
64 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
65 bool CanUseMagic() const { return MaxMana() > 0; }
67 Uint8 MaxIP() const { return 255; }
68 Uint8 IP() const { return ip; }
69 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
71 Stats &GetStats() { return stats; }
72 const Stats &GetStats() const { return stats; }
74 Uint8 Level() const { return level; }
75 int Experience() const { return experience; }
76 int NextLevel() const;
78 void AddExperience(int, std::vector<Upgrade> &);
80 bool CanEquip(const Item &) const;
81 bool CanInvoke(const Spell &) const;
83 const Item *Equipment(EquipSlot i) const { return equipment[i]; }
84 bool Equipped(EquipSlot i) const { return equipment[i]; }
85 void RemoveEquipment(EquipSlot i) { equipment[i] = 0; }
86 void SetEquipment(EquipSlot i, const Item *item) { equipment[i] = item; }
88 std::vector<const Spell *> &Spells() { return spells; }
89 const std::vector<const Spell *> &Spells() const { return spells; }
91 graphics::Sprite *BattleSprite() { return battleSprite; }
92 const graphics::Sprite *BattleSprite() const { return battleSprite; }
93 graphics::Animation *MeleeAnimation() { return meleeAnimation; }
94 graphics::Animation *AttackAnimation() { return attackAnimation; }
95 graphics::Animation *SpellAnimation() { return spellAnimation; }
97 map::Entity &MapEntity() { return mapEntity; }
98 const map::Entity &MapEntity() const { return mapEntity; }
100 static void CreateTypeDescription();
101 static void Construct(void *);
104 void SetMaxHealth(int h) { maxHealth = h; }
105 void SetHealth(int h) { health = h; }
106 void AddSpell(Spell *s) { spells.push_back(s); }
111 int maxHealth, health;
120 LevelUp *levelLadder;
125 const Item *equipment[EQUIP_COUNT];
127 // TODO: vector does not seem to be a good choice
128 std::vector<const Spell *> spells;
130 graphics::Sprite *battleSprite;
131 graphics::Animation *meleeAnimation;
132 graphics::Animation *attackAnimation;
133 graphics::Animation *spellAnimation;
135 map::Entity mapEntity;