15 #include "../map/Entity.h"
24 static const int TYPE_ID = 301;
54 const char *Name() const { return name; }
56 Uint16 MaxHealth() const { return maxHealth; }
57 Uint16 Health() const { return health; }
58 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
59 void SubtractHealth(int amount);
61 Uint16 MaxMana() const { return maxMana; }
62 Uint16 Mana() const { return mana; }
63 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
64 bool CanUseMagic() const { return MaxMana() > 0; }
66 Uint8 MaxIP() const { return 255; }
67 Uint8 IP() const { return ip; }
68 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
70 Stats &GetStats() { return stats; }
71 const Stats &GetStats() const { return stats; }
73 Uint8 Level() const { return level; }
74 int Experience() const { return experience; }
75 int NextLevel() const;
77 void AddExperience(int, std::vector<Upgrade> &);
79 bool CanEquip(const Item &) const;
80 bool CanInvoke(const Spell &) const;
82 const Item *Equipment(EquipSlot i) const { return equipment[i]; }
83 bool Equipped(EquipSlot i) const { return equipment[i]; }
84 void RemoveEquipment(EquipSlot i) { equipment[i] = 0; }
85 void SetEquipment(EquipSlot i, const Item *item) { equipment[i] = item; }
87 std::vector<const Spell *> &Spells() { return spells; }
88 const std::vector<const Spell *> &Spells() const { return spells; }
90 graphics::Sprite *BattleSprite() { return battleSprite; }
91 const graphics::Sprite *BattleSprite() const { return battleSprite; }
92 graphics::Animation *MeleeAnimation() { return meleeAnimation; }
93 graphics::Animation *AttackAnimation() { return attackAnimation; }
94 graphics::Animation *SpellAnimation() { return spellAnimation; }
96 map::Entity &MapEntity() { return mapEntity; }
97 const map::Entity &MapEntity() const { return mapEntity; }
99 static void CreateTypeDescription();
100 static void Construct(void *);
103 void SetMaxHealth(int h) { maxHealth = h; }
104 void SetHealth(int h) { health = h; }
105 void AddSpell(Spell *s) { spells.push_back(s); }
110 int maxHealth, health;
119 // TODO: ladder should contain hp, mp, and stats mods.
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;