X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHero.h;h=3274fe21b64d7a2cb373d9a12bce7c061a77abff;hb=3f2e68e7a2377db6d1738934150f34b80bdbd0e0;hp=ec87f4944cec872225fdff869c9306c3cf229968;hpb=d997e6743dfa0df245bc3f59ee97ecd63efb3c4f;p=l2e.git diff --git a/src/battle/Hero.h b/src/battle/Hero.h index ec87f49..3274fe2 100644 --- a/src/battle/Hero.h +++ b/src/battle/Hero.h @@ -8,8 +8,13 @@ #ifndef BATTLE_HERO_H_ #define BATTLE_HERO_H_ +#include #include +namespace common { + class Item; + class Spell; +} namespace graphics { class Sprite; } namespace battle { @@ -25,13 +30,20 @@ public: Uint8 Level() const { return level; } const graphics::Sprite *Sprite() const { return sprite; } + const std::vector &Spells() const { return spells; } + Uint16 MaxHealth() const { return maxHealth; } Uint16 Health() const { return health; } - int RelativeHealth(int max) { 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) { return mana * max / maxMana; } + 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 / MaxIP(); } Uint16 Attack() const { return attack; } Uint16 Defense() const { return defense; } @@ -40,14 +52,63 @@ 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; } + + int AttackFrames() const { return attackFrames; } + int SpellFrames() const { return spellFrames; } + // temporary setters until loader is implemented public: + void SetName(const char *n) { name = n; } + void SetLevel(Uint8 l) { level = l; } void SetSprite(graphics::Sprite *s) { sprite = s; } + void SetMaxHealth(Uint16 h) { maxHealth = h; } + void SetHealth(Uint16 h) { health = h; } + void SetMaxMana(Uint16 m) { maxMana = m; } + 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); } + + void SetAttackFrames(int num) { attackFrames = num; } + void SetSpellFrames(int num) { spellFrames = num; } + private: const char *name; graphics::Sprite *sprite; - // TODO: equipment and spells lists + + 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 spells; + + int attackFrames; + int spellFrames; Uint16 maxHealth, health; Uint16 maxMana, mana; @@ -60,6 +121,7 @@ private: Uint16 magicResistance; Uint8 level; + Uint8 ip; };