]> git.localhorst.tv Git - l2e.git/commitdiff
removed redundant BattleState::AttackChoiceAt(int)
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 21 Aug 2012 19:18:25 +0000 (21:18 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 21 Aug 2012 19:18:25 +0000 (21:18 +0200)
src/battle/BattleState.cpp
src/battle/BattleState.h
src/battle/HeroTag.cpp
src/battle/states/PerformAttacks.cpp

index 50121049651fc4b0a4deacb7c40554dcdc21400a..720d70802c161b22a0cc451fd6db89d419713538 100644 (file)
@@ -218,7 +218,7 @@ bool BattleState::AttacksFinished() const {
 }
 
 void BattleState::CalculateDamage() {
-       AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : AttackChoiceAt(CurrentAttack().index));
+       AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : HeroAt(CurrentAttack().index).GetAttackChoice());
        if (ac.GetType() == AttackChoice::DEFEND) return;
 
        if (CurrentAttack().isMonster) {
@@ -294,7 +294,7 @@ Uint16 BattleState::CalculateDamage(const Stats &attacker, const Stats &defender
 
 void BattleState::ApplyDamage() {
        if (attackCursor < 0) return;
-       AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : AttackChoiceAt(CurrentAttack().index));
+       AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : HeroAt(CurrentAttack().index).GetAttackChoice());
        TargetSelection &ts(ac.Selection());
        if (ts.TargetsEnemies()) {
                for (int i(0); i < MaxMonsters(); ++i) {
@@ -321,7 +321,7 @@ AttackChoice &BattleState::CurrentAttackAttackChoice() {
        if (CurrentAttack().isMonster) {
                return monsterAttacks[CurrentAttack().index];
        } else {
-               return AttackChoiceAt(CurrentAttack().index);
+               return HeroAt(CurrentAttack().index).GetAttackChoice();
        }
 }
 
index bac9647590917e4cdf9aa547a9e7f619a066f26c..a64ea0e3306baf9f90431c00ed23dd8771de467a 100644 (file)
@@ -107,8 +107,6 @@ public:
        const geometry::Point<int> &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; }
 
        bool HasChosenAttackType() const { return ActiveHero().GetAttackChoice().GetType() != AttackChoice::UNDECIDED; }
-       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; }
index f6682df4e5da9df1b424d65ceb3ca7ee07d96d71..228bfda4aef5e654a368c8c1634460f4ca890541 100644 (file)
@@ -87,9 +87,9 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> posi
        r.normalFont->DrawString(hero.Name(), screen, position + frameOffset + alignOffset, 5);
 
        // attack icon
-       if (battle->AttackChoiceAt(index).GetType() != AttackChoice::UNDECIDED) {
+       if (battle->HeroAt(index).GetAttackChoice().GetType() != AttackChoice::UNDECIDED) {
                Vector<int> attackIconOffset(labelX + r.heroTagLabels->Width(), frameOffset.Y() + 3 * r.heroTagFont->CharHeight());
-               r.attackChoiceIcons->Draw(screen, position + attackIconOffset, 0, battle->AttackChoiceAt(index).GetType());
+               r.attackChoiceIcons->Draw(screen, position + attackIconOffset, 0, battle->HeroAt(index).GetAttackChoice().GetType());
        }
 
        // hero
index 05227e6e4065f512aef1af9bb7cabfd053076bb2..0faecf9b5ead48f334e663c0817cb185abb1311f 100644 (file)
@@ -80,7 +80,7 @@ void PerformAttacks::HandleEvents(const Input &input) {
                AddNumberAnimations(battle->MonsterAttackChoiceAt(battle->CurrentAttack().index).Selection());
        } else {
                Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
-               const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));
+               const AttackChoice &ac(battle->HeroAt(battle->CurrentAttack().index).GetAttackChoice());
 
                switch (ac.GetType()) {
                        case AttackChoice::SWORD: