]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.h
moved spell and ikari menu initialization to Hero
[l2e.git] / src / battle / BattleState.h
index ab9f731a9c838e0d9e5430bb491007c0353b35a3..3561609e91c105a34413a8b29d042d7d1a0c50ce 100644 (file)
@@ -8,7 +8,6 @@
 #ifndef BATTLE_BATTLESTATE_H_
 #define BATTLE_BATTLESTATE_H_
 
-#include "AttackChoice.h"
 #include "AttackTypeMenu.h"
 #include "Hero.h"
 #include "HeroTag.h"
@@ -41,6 +40,7 @@ namespace graphics {
 
 namespace battle {
 
+class AttackChoice;
 class PartyLayout;
 class Stats;
 
@@ -58,6 +58,8 @@ public:
        , numHeroes(0)
        , activeHero(-1)
        , attackCursor(-1)
+       , expReward(0)
+       , goldReward(0)
        , ranAway(false) { assert(background && res); }
 
 public:
@@ -76,15 +78,16 @@ public:
        virtual void UpdateWorld(float deltaT);
        virtual void Render(SDL_Surface *);
 
+       // TODO: turn this mess into a well stuctured interface
 public:
        const Resources &Res() const { return *res; }
        AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
        MoveMenu &GetMoveMenu() { return moveMenu; }
 
-       graphics::Menu<const common::Spell *> &GetSpellMenu() { return spellMenus[activeHero]; }
-       const graphics::Menu<const common::Spell *> &GetSpellMenu() const { return spellMenus[activeHero]; }
-       graphics::Menu<const common::Item *> &GetIkariMenu() { return ikariMenus[activeHero]; }
-       const graphics::Menu<const common::Item *> &GetIkariMenu() const { return ikariMenus[activeHero]; }
+       graphics::Menu<const common::Spell *> &GetSpellMenu() { return heroes[activeHero].SpellMenu(); }
+       const graphics::Menu<const common::Spell *> &GetSpellMenu() const { return heroes[activeHero].SpellMenu(); }
+       graphics::Menu<const common::Item *> &GetIkariMenu() { return heroes[activeHero].IkariMenu(); }
+       const graphics::Menu<const common::Item *> &GetIkariMenu() const { return heroes[activeHero].IkariMenu(); }
        graphics::Menu<const common::Item *> &GetItemMenu() { return itemMenu; }
        const graphics::Menu<const common::Item *> &GetItemMenu() const { return itemMenu; }
 
@@ -106,8 +109,10 @@ public:
        bool HasChosenAttackType() const { return ActiveHeroAttackChoice().GetType() != AttackChoice::UNDECIDED; }
        AttackChoice &ActiveHeroAttackChoice() { return AttackChoiceAt(activeHero); }
        const AttackChoice &ActiveHeroAttackChoice() const { return AttackChoiceAt(activeHero); }
-       AttackChoice &AttackChoiceAt(int index) { assert(index >= 0 && index < NumHeroes()); return attackChoices[index]; }
-       const AttackChoice &AttackChoiceAt(int index) const { assert(index >= 0 && index < NumHeroes()); return attackChoices[index]; }
+       AttackChoice &AttackChoiceAt(int index) { assert(index >= 0 && index < NumHeroes()); return heroes[index].GetAttackChoice(); }
+       const AttackChoice &AttackChoiceAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroes[index].GetAttackChoice(); }
+       AttackChoice &MonsterAttackChoiceAt(int index) { assert(index >= 0 && index < MaxMonsters()); return monsterAttacks[index]; }
+       const AttackChoice &MonsterAttackChoiceAt(int index) const { assert(index >= 0 && index < MaxMonsters()); return monsterAttacks[index]; }
        bool AttackSelectionDone() const { return activeHero >= numHeroes; }
 
        int NumHeroes() const { return numHeroes; }
@@ -134,6 +139,7 @@ public:
        void CalculateDamage();
        void ApplyDamage();
        const Order &CurrentAttack() const { assert(attackCursor >= 0 && attackCursor < int(attackOrder.size())); return attackOrder[attackCursor]; };
+       AttackChoice &CurrentAttackAttackChoice();
        void ClearAllAttacks();
 
        bool Victory() const;
@@ -155,8 +161,6 @@ public:
        void RenderSmallHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
 
 private:
-       void LoadSpellMenu(std::vector<Hero>::size_type heroIndex);
-       void LoadIkariMenu(std::vector<Hero>::size_type heroIndex);
        void LoadInventory();
 
        Uint16 CalculateDamage(const Stats &attacker, const Stats &defender) const;
@@ -175,17 +179,16 @@ private:
        std::vector<AttackChoice> monsterAttacks;
        std::vector<Order> attackOrder;
        Hero heroes[4];
-       graphics::Menu<const common::Spell *> spellMenus[4];
        graphics::Menu<const common::Item *> itemMenu;
-       graphics::Menu<const common::Item *> ikariMenus[4];
        HeroTag heroTags[4];
        SmallHeroTag smallHeroTags[4];
        geometry::Point<int> heroTagPositions[4];
        geometry::Point<int> smallHeroTagPositions[4];
-       AttackChoice attackChoices[4];
        int numHeroes;
        int activeHero;
        int attackCursor;
+       int expReward;
+       int goldReward;
        bool ranAway;
 
 };