]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.h
made battle's heroes into an array
[l2e.git] / src / battle / BattleState.h
index 7dbd016d8717ff8415a1ed63aa8d0f717ffbd54d..978581f3062843018925d782ecf63d5de3995d46 100644 (file)
@@ -51,6 +51,7 @@ public:
        , res(res)
        , attackTypeMenu(res->attackIcons)
        , moveMenu(res->moveIcons)
+       , numHeroes(0)
        , activeHero(-1)
        , ranAway(false) { }
 
@@ -75,28 +76,28 @@ public:
        AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
        MoveMenu &GetMoveMenu() { return moveMenu; }
 
-       bool HasMoreHeroes() const { return activeHero < (int) heroes.size(); }
+       bool HasMoreHeroes() const { return activeHero < numHeroes; }
        void NextHero() { ++activeHero; }
        bool BeforeFirstHero() const { return activeHero < 0; }
        void PreviousHero() { --activeHero; }
        Hero &ActiveHero() { return heroes[activeHero]; }
        const Hero &ActiveHero() const { return heroes[activeHero]; }
-       Hero &HeroAt(std::vector<Hero>::size_type index) { return heroes[index]; }
-       const Hero &HeroAt(std::vector<Hero>::size_type index) const { return heroes[index]; }
+       Hero &HeroAt(int index) { return heroes[index]; }
+       const Hero &HeroAt(int index) const { return heroes[index]; }
        Monster &MonsterAt(std::vector<Monster>::size_type index) { return monsters[index]; }
        const Monster &MonsterAt(std::vector<Monster>::size_type index) const { return monsters[index]; }
-       void SwapHeroes(std::vector<Hero>::size_type lhs, std::vector<Hero>::size_type rhs);
+       void SwapHeroes(int lhs, int rhs);
        const HeroTag &ActiveHeroTag() const { return heroTags[activeHero]; }
-       const HeroTag &HeroTagAt(std::vector<Hero>::size_type index) const { return heroTags[index]; }
-       const geometry::Point<int> &HeroTagPositionAt(std::vector<Hero>::size_type index) const { return heroTagPositions[index]; }
+       const HeroTag &HeroTagAt(int index) const { return heroTags[index]; }
+       const geometry::Point<int> &HeroTagPositionAt(int index) const { return heroTagPositions[index]; }
        bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
        void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
        AttackChoice &ActiveHeroAttackChoice() { return attackChoices[activeHero]; }
        const AttackChoice &ActiveHeroAttackChoice() const { return attackChoices[activeHero]; }
-       const AttackChoice &AttackChoiceAt(std::vector<Hero>::size_type index) const { return attackChoices[index]; }
+       const AttackChoice &AttackChoiceAt(int index) const { return attackChoices[index]; }
        TargetSelection &ActiveHeroTargets() { return attackChoices[activeHero].Selection(); }
        const TargetSelection &ActiveHeroTargets() const { return attackChoices[activeHero].Selection(); }
-       bool AttackSelectionDone() const { return activeHero >= (int) heroes.size(); }
+       bool AttackSelectionDone() const { return activeHero >= numHeroes; }
 
        graphics::Menu<const common::Spell *> &GetSpellMenu() { return spellMenus[activeHero]; }
        const graphics::Menu<const common::Spell *> &GetSpellMenu() const { return spellMenus[activeHero]; }
@@ -108,9 +109,8 @@ public:
        const std::vector<geometry::Point<int> > &MonsterPositions() const { return monsterPositions; }
        bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; }
        const std::vector<geometry::Point<int> > &HeroesPositions() const { return heroesPositions; }
-       bool HeroPositionOccupied(int index) { return index >= 0 && index < int(heroes.size()); }
-       std::vector<Hero> &Heroes() { return heroes; }
-       const std::vector<Hero> &Heroes() const { return heroes; }
+       bool HeroPositionOccupied(int index) { return index >= 0 && index < numHeroes; }
+       int NumHeroes() const { return numHeroes; }
        std::vector<Monster> &Monsters() { return monsters; }
        const std::vector<Monster> &Monsters() const { return monsters; }
 
@@ -147,13 +147,14 @@ private:
        std::vector<geometry::Point<int> > monsterPositions;
        std::vector<geometry::Point<int> > heroesPositions;
        std::vector<Monster> monsters;
-       std::vector<Hero> heroes;
+       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];
        geometry::Point<int> heroTagPositions[4];
        AttackChoice attackChoices[4];
+       int numHeroes;
        int activeHero;
        bool ranAway;