]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/Hero.h
added hero equipment
[l2e.git] / src / battle / Hero.h
index 03f909519400ffac8685e92b9b97301fd29425ae..499239d961beefa21410a3464d4e147eb2c86565 100644 (file)
 #include <vector>
 #include <SDL.h>
 
-namespace common { class Spell; }
+namespace common {
+       class Item;
+       class Spell;
+}
 namespace graphics { class Sprite; }
 
 namespace battle {
@@ -31,15 +34,16 @@ public:
 
        Uint16 MaxHealth() const { return maxHealth; }
        Uint16 Health() const { return health; }
-       int RelativeHealth(int max) const { return health * max / maxHealth; }
+       int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
 
        Uint16 MaxMana() const { return maxMana; }
        Uint16 Mana() const { return mana; }
-       int RelativeMana(int max) const { return maxMana == 0 ? 0 : mana * max / maxMana; }
-       bool CanUseMagic() const { return maxMana > 0; }
+       int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); }
+       bool CanUseMagic() const { return MaxMana() > 0; }
 
+       Uint8 MaxIP() const { return 255; }
        Uint8 IP() const { return ip; }
-       int RelativeIP(int max) const { return ip * max / 255; }
+       int RelativeIP(int max) const { return IP() * max / MaxIP(); }
 
        Uint16 Attack() const { return attack; }
        Uint16 Defense() const { return defense; }
@@ -48,6 +52,20 @@ public:
        Uint16 Gut() const { return gut; }
        Uint16 MagicResistance() const { return magicResistance; }
 
+       const common::Item *Weapon() const { return weapon; }
+       const common::Item *Armor() const { return armor; }
+       const common::Item *Shield() const { return shield; }
+       const common::Item *Helmet() const { return helmet; }
+       const common::Item *Ring() const { return ring; }
+       const common::Item *Jewel() const { return jewel; }
+
+       bool HasWeapon() const { return weapon; }
+       bool HasArmor() const { return armor; }
+       bool HasShield() const { return shield; }
+       bool HasHelmet() const { return helmet; }
+       bool HasRing() const { return ring; }
+       bool HasJewel() const { return jewel; }
+
 // temporary setters until loader is implemented
 public:
        void SetName(const char *n) { name = n; }
@@ -60,12 +78,26 @@ public:
        void SetMana(Uint16 m) { mana = m; }
        void SetIP(Uint8 i) { ip = i; }
 
+       void SetWeapon(const common::Item *i) { weapon = i; }
+       void SetArmor(const common::Item *i) { armor = i; }
+       void SetShield(const common::Item *i) { shield = i; }
+       void SetHelmet(const common::Item *i) { helmet = i; }
+       void SetRing(const common::Item *i) { ring = i; }
+       void SetJewel(const common::Item *i) { jewel = i; }
+
        void AddSpell(const common::Spell *s) { spells.push_back(s); }
 
 private:
        const char *name;
        graphics::Sprite *sprite;
 
+       const common::Item *weapon;
+       const common::Item *armor;
+       const common::Item *shield;
+       const common::Item *helmet;
+       const common::Item *ring;
+       const common::Item *jewel;
+
        // TODO: vector does not seem to be a good choice
        std::vector<const common::Spell *> spells;
        // TODO: equipment list