From c68b073db752dcdcf8c900efba7d8a5da091751c Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 21 Aug 2012 21:18:25 +0200 Subject: [PATCH] removed redundant BattleState::AttackChoiceAt(int) --- src/battle/BattleState.cpp | 6 +++--- src/battle/BattleState.h | 2 -- src/battle/HeroTag.cpp | 4 ++-- src/battle/states/PerformAttacks.cpp | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 5012104..720d708 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -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(); } } diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index bac9647..a64ea0e 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -107,8 +107,6 @@ public: const geometry::Point &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; } diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index f6682df..228bfda 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -87,9 +87,9 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point 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 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 diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 05227e6..0faecf9 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -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: -- 2.39.2