14 #include "../map/Entity.h"
23 static const int TYPE_ID = 301;
53 const char *Name() const { return name; }
55 Uint16 MaxHealth() const { return maxHealth; }
56 Uint16 Health() const { return health; }
57 int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
58 void SubtractHealth(int amount);
60 Uint16 MaxMana() const { return maxMana; }
61 Uint16 Mana() const { return mana; }
62 int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
63 bool CanUseMagic() const { return MaxMana() > 0; }
65 Uint8 MaxIP() const { return 255; }
66 Uint8 IP() const { return ip; }
67 int RelativeIP(int max) const { return IP() * max / MaxIP(); }
69 Stats &GetStats() { return stats; }
70 const Stats &GetStats() const { return stats; }
72 Uint8 Level() const { return level; }
73 int Experience() const { return experience; }
74 int NextLevel() const;
79 UpgradeInfo(UpgradeType t, int a = 0)
80 : type(t), amount(a) { }
82 void AddExperience(int, std::vector<UpgradeInfo> &);
84 bool CanEquip(const Item &) const;
85 bool CanInvoke(const Spell &) const;
87 const Item *Equipment(EquipSlot i) const { return equipment[i]; }
88 bool Equipped(EquipSlot i) const { return equipment[i]; }
89 void RemoveEquipment(EquipSlot i) { equipment[i] = 0; }
90 void SetEquipment(EquipSlot i, const Item *item) { equipment[i] = item; }
92 std::vector<const Spell *> &Spells() { return spells; }
93 const std::vector<const Spell *> &Spells() const { return spells; }
95 graphics::Sprite *BattleSprite() { return battleSprite; }
96 const graphics::Sprite *BattleSprite() const { return battleSprite; }
97 graphics::Animation *MeleeAnimation() { return meleeAnimation; }
98 graphics::Animation *AttackAnimation() { return attackAnimation; }
99 graphics::Animation *SpellAnimation() { return spellAnimation; }
101 map::Entity &MapEntity() { return mapEntity; }
102 const map::Entity &MapEntity() const { return mapEntity; }
104 static void CreateTypeDescription();
105 static void Construct(void *);
108 void SetMaxHealth(int h) { maxHealth = h; }
109 void SetHealth(int h) { health = h; }
110 void AddSpell(Spell *s) { spells.push_back(s); }
115 int maxHealth, health;
124 // TODO: ladder should contain hp, mp, and stats mods.
130 const Item *equipment[EQUIP_COUNT];
132 // TODO: vector does not seem to be a good choice
133 std::vector<const Spell *> spells;
135 graphics::Sprite *battleSprite;
136 graphics::Animation *meleeAnimation;
137 graphics::Animation *attackAnimation;
138 graphics::Animation *spellAnimation;
140 map::Entity mapEntity;