X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHero.h;h=7abfb68fb35ae5f8a0cd16e243678546cf58074e;hb=fbf5a98f8fd0da951e469003fe87d575a6bb30a4;hp=d7f6a49d97b0a89efaeffe8c752d46db5484f922;hpb=e70b263430990055abc58945aa385e52d935431d;p=l2e.git diff --git a/src/battle/Hero.h b/src/battle/Hero.h index d7f6a49..7abfb68 100644 --- a/src/battle/Hero.h +++ b/src/battle/Hero.h @@ -8,9 +8,17 @@ #ifndef BATTLE_HERO_H_ #define BATTLE_HERO_H_ +#include #include -namespace graphics { class Sprite; } +namespace common { + class Item; + class Spell; +} +namespace graphics { + class Animation; + class Sprite; +} namespace battle { @@ -25,16 +33,21 @@ 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) const { return health * max / maxHealth; } + int RelativeHealth(int max) const { return Health() * max / MaxHealth(); } + void SubtractHealth(int amount); Uint16 MaxMana() const { return maxMana; } Uint16 Mana() const { return mana; } - int RelativeMana(int max) const { 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 / 255; } + int RelativeIP(int max) const { return IP() * max / MaxIP(); } Uint16 Attack() const { return attack; } Uint16 Defense() const { return defense; } @@ -43,6 +56,34 @@ public: Uint16 Gut() const { return gut; } Uint16 MagicResistance() const { return magicResistance; } + common::Item *Weapon() { return weapon; } + common::Item *Armor() { return armor; } + common::Item *Shield() { return shield; } + common::Item *Helmet() { return helmet; } + common::Item *Ring() { return ring; } + common::Item *Jewel() { return jewel; } + + 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; } + + graphics::Animation *MeleeAnimation() { return meleeAnimation; } + const graphics::Animation *MeleeAnimation() const { return meleeAnimation; } + graphics::Animation *AttackAnimation() { return attackAnimation; } + const graphics::Animation *AttackAnimation() const { return attackAnimation; } + graphics::Animation *SpellAnimation() { return spellAnimation; } + const graphics::Animation *SpellAnimation() const { return spellAnimation; } + // temporary setters until loader is implemented public: void SetName(const char *n) { name = n; } @@ -55,10 +96,36 @@ public: void SetMana(Uint16 m) { mana = m; } void SetIP(Uint8 i) { ip = i; } + void SetWeapon(common::Item *i) { weapon = i; } + void SetArmor(common::Item *i) { armor = i; } + void SetShield(common::Item *i) { shield = i; } + void SetHelmet(common::Item *i) { helmet = i; } + void SetRing(common::Item *i) { ring = i; } + void SetJewel(common::Item *i) { jewel = i; } + + void AddSpell(const common::Spell *s) { spells.push_back(s); } + + void SetMeleeAnimation(graphics::Animation *a) { meleeAnimation = a; } + void SetAttackAnimation(graphics::Animation *a) { attackAnimation = a; } + void SetSpellAnimation(graphics::Animation *a) { spellAnimation = a; } + private: const char *name; graphics::Sprite *sprite; - // TODO: equipment and spells lists + + common::Item *weapon; + common::Item *armor; + common::Item *shield; + common::Item *helmet; + common::Item *ring; + common::Item *jewel; + + graphics::Animation *meleeAnimation; + graphics::Animation *attackAnimation; + graphics::Animation *spellAnimation; + + // TODO: vector does not seem to be a good choice + std::vector spells; Uint16 maxHealth, health; Uint16 maxMana, mana;