X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.cpp;h=b5c91f8ca6b03587bf9605111ed0e6814097e1c9;hb=222167ba3722dc7f47ff7510006bd516e0010a50;hp=b3ad20ede3ef4a15aec0ffb214aeccc8a74dfbba;hpb=85f12b6b3dd4abb488a24b41d2d5d9725fb33462;p=l2e.git diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index b3ad20e..b5c91f8 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -9,6 +9,7 @@ #include "PartyLayout.h" #include "states/SelectMoveAction.h" +#include "states/PerformAttacks.h" #include "../app/Application.h" #include "../app/Input.h" #include "../common/Ikari.h" @@ -180,6 +181,7 @@ void BattleState::LoadInventory() { itemMenu.AddEmptyEntry(); } } + ClearAllAttacks(); } void BattleState::ExitState(Application &ctrl, SDL_Surface *screen) { @@ -187,13 +189,16 @@ void BattleState::ExitState(Application &ctrl, SDL_Surface *screen) { } void BattleState::ResumeState(Application &ctrl, SDL_Surface *screen) { - // TODO: check for victory, defeat or run - // reset attack choices - activeHero = -1; - for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { - attackChoices[i] = AttackChoice(this); + // TODO: check for victory or defeat + if (ranAway) { + ctrl.PopState(); // quit the battle scene + return; + } + if (AttackSelectionDone()) { + ctrl.PushState(new PerformAttacks(this)); + } else { + ctrl.PushState(new SelectMoveAction(this)); } - ctrl.PushState(new SelectMoveAction(this)); } void BattleState::PauseState(Application &ctrl, SDL_Surface *screen) { @@ -201,6 +206,14 @@ void BattleState::PauseState(Application &ctrl, SDL_Surface *screen) { } +void BattleState::ClearAllAttacks() { + activeHero = -1; + for (vector::size_type i(0), end(heroes.size()); i < end; ++i) { + attackChoices[i] = AttackChoice(this); + } +} + + void BattleState::HandleEvents(const Input &input) { }