]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/Hero.h
added simple victory state
[l2e.git] / src / battle / Hero.h
index 1cce110df994e3af3fef811581bbc4016df6803b..df23aa10162e965babba702dfba38982fd195b6f 100644 (file)
@@ -1,95 +1,83 @@
-/*
- * Hero.h
- *
- *  Created on: Aug 6, 2012
- *      Author: holy
- */
-
 #ifndef BATTLE_HERO_H_
 #define BATTLE_HERO_H_
 
+namespace battle {
+       struct Resources;
+}
+namespace math {
+       template<class>
+       class Vector;
+}
+
 #include "AttackChoice.h"
-#include "Stats.h"
-#include "../geometry/Vector.h"
+#include "../common/Hero.h"
+#include "../common/Stats.h"
 #include "../graphics/Animation.h"
 #include "../graphics/Menu.h"
 
 #include <vector>
 #include <SDL.h>
 
-namespace common {
-       class Item;
-       class Spell;
-}
-namespace graphics {
-       class Sprite;
-}
-
 namespace battle {
 
-class Resources;
-
 class Hero {
 
 public:
        Hero();
+       Hero(common::Hero &);
        ~Hero();
 
 public:
-       const char *Name() const { return name; }
-       Uint8 Level() const { return level; }
-       const graphics::Sprite *Sprite() const { return sprite; }
+       common::Hero &Master() { return *master; }
+       const common::Hero &Master() const { return *master; }
 
-       const std::vector<const common::Spell *> &Spells() const { return spells; }
+       const char *Name() const { return master->Name(); }
+       Uint8 Level() const { return master->Level(); }
+       const graphics::Sprite *Sprite() const { return master->BattleSprite(); }
 
-       Uint16 MaxHealth() const { return maxHealth; }
-       Uint16 Health() const { return health; }
+       const std::vector<const common::Spell *> &Spells() const { return master->Spells(); }
+
+       Uint16 MaxHealth() const { return master->MaxHealth(); }
+       Uint16 Health() const { return master->Health(); }
        int RelativeHealth(int max) const { return Health() * max / MaxHealth(); }
-       void SubtractHealth(int amount);
+       void SubtractHealth(int amount) { master->SubtractHealth(amount); }
 
-       Uint16 MaxMana() const { return maxMana; }
-       Uint16 Mana() const { return mana; }
+       Uint16 MaxMana() const { return master->MaxMana(); }
+       Uint16 Mana() const { return master->Mana(); }
        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; }
+       Uint8 MaxIP() const { return master->MaxIP(); }
+       Uint8 IP() const { return master->IP(); }
        int RelativeIP(int max) const { return IP() * max / MaxIP(); }
 
-       Stats &GetStats() { return stats; }
-       const Stats &GetStats() const { return stats; }
-
-       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; }
+       common::Stats &GetStats() { return stats; }
+       const common::Stats &GetStats() const { return stats; }
+
+       const common::Item *Weapon() const { return master->Equipment(common::Hero::EQUIP_WEAPON); }
+       const common::Item *Armor() const { return master->Equipment(common::Hero::EQUIP_ARMOR); }
+       const common::Item *Shield() const { return master->Equipment(common::Hero::EQUIP_SHIELD); }
+       const common::Item *Helmet() const { return master->Equipment(common::Hero::EQUIP_HELMET); }
+       const common::Item *Ring() const { return master->Equipment(common::Hero::EQUIP_RING); }
+       const common::Item *Jewel() const { return master->Equipment(common::Hero::EQUIP_JEWEL); }
+
+       bool HasWeapon() const { return master->Equipped(common::Hero::EQUIP_WEAPON); }
+       bool HasArmor() const { return master->Equipped(common::Hero::EQUIP_ARMOR); }
+       bool HasShield() const { return master->Equipped(common::Hero::EQUIP_SHIELD); }
+       bool HasHelmet() const { return master->Equipped(common::Hero::EQUIP_HELMET); }
+       bool HasRing() const { return master->Equipped(common::Hero::EQUIP_RING); }
+       bool HasJewel() const { return master->Equipped(common::Hero::EQUIP_JEWEL); }
 
        graphics::AnimationRunner &GetAnimation() { return animation; }
        const graphics::AnimationRunner &GetAnimation() const { return animation; }
        void SetAnimation(const graphics::AnimationRunner &a) { animation = a; }
 
-       const graphics::Animation *MeleeAnimation() const { return meleeAnimation; }
-       const graphics::Animation *AttackAnimation() const { return attackAnimation; }
-       const graphics::Animation *SpellAnimation() const { return spellAnimation; }
+       const graphics::Animation *MeleeAnimation() const { return master->MeleeAnimation(); }
+       const graphics::Animation *AttackAnimation() const { return master->AttackAnimation(); }
+       const graphics::Animation *SpellAnimation() const { return master->SpellAnimation(); }
 
-       geometry::Vector<int> &Position() { return position; }
-       const geometry::Vector<int> &Position() const { return position; }
+       math::Vector<int> &Position() { return position; }
+       const math::Vector<int> &Position() const { return position; }
 
        graphics::Menu<const common::Spell *> &SpellMenu() { return spellMenu; }
        const graphics::Menu<const common::Spell *> &SpellMenu() const { return spellMenu; }
@@ -103,70 +91,22 @@ public:
        void UpdateSpellMenu();
        void UpdateIkariMenu(const Resources *);
 
-// 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 SetStats(const Stats &s) { stats = s; }
-
-       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(const graphics::Animation *a) { meleeAnimation = a; }
-       void SetAttackAnimation(const graphics::Animation *a) { attackAnimation = a; }
-       void SetSpellAnimation(const graphics::Animation *a) { spellAnimation = a; }
-
 private:
-       const char *name;
-       graphics::Sprite *sprite;
-
-       common::Item *weapon;
-       common::Item *armor;
-       common::Item *shield;
-       common::Item *helmet;
-       common::Item *ring;
-       common::Item *jewel;
-
-       const graphics::Animation *meleeAnimation;
-       const graphics::Animation *attackAnimation;
-       const graphics::Animation *spellAnimation;
+       common::Hero *master;
 
        graphics::AnimationRunner animation;
 
-       geometry::Vector<int> position;
+       math::Vector<int> position;
 
        graphics::Menu<const common::Spell *> spellMenu;
        graphics::Menu<const common::Item *> ikariMenu;
 
        AttackChoice attackChoice;
 
-       // TODO: vector does not seem to be a good choice
-       std::vector<const common::Spell *> spells;
-
-       Uint16 maxHealth, health;
-       Uint16 maxMana, mana;
-
-       Stats stats;
-
-       Uint8 level;
-       Uint8 ip;
+       common::Stats stats;
 
 };
 
 }
 
-#endif /* BATTLE_HERO_H_ */
+#endif