X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectAttackType.cpp;h=786277d764900f036dbfffca578d3eacfd0db114;hb=536a8c96ebfec2a2b34f680d3d0b97db8e66d599;hp=c7a65be7a3ade4d69d9c54895d2248d24ac587d0;hpb=2a0eca649009f78028db286a67a532429cab5b88;p=l2e.git diff --git a/src/battle/states/SelectAttackType.cpp b/src/battle/states/SelectAttackType.cpp index c7a65be..786277d 100644 --- a/src/battle/states/SelectAttackType.cpp +++ b/src/battle/states/SelectAttackType.cpp @@ -7,6 +7,10 @@ #include "SelectAttackType.h" +#include "SelectIkari.h" +#include "SelectItem.h" +#include "SelectMoveAction.h" +#include "SelectSpell.h" #include "../AttackChoice.h" #include "../BattleState.h" #include "../../app/Application.h" @@ -31,7 +35,10 @@ void SelectAttackType::ExitState(Application &c, SDL_Surface *screen) { } void SelectAttackType::ResumeState(Application &ctrl, SDL_Surface *screen) { - + if (battle->AttackSelectionDone()) { + // pass through + ctrl.PopState(); + } } void SelectAttackType::PauseState(Application &ctrl, SDL_Surface *screen) { @@ -58,26 +65,36 @@ void SelectAttackType::HandleInput(const Input &input) { } if (input.JustPressed(Input::ACTION_A)) { - battle->SetAttackType(battle->GetAttackTypeMenu().Selected()); switch (battle->GetAttackTypeMenu().Selected()) { case AttackChoice::SWORD: + // TODO: switch to target select + battle->SetAttackType(AttackChoice::SWORD); battle->NextHero(); break; case AttackChoice::MAGIC: - // TODO: switch to spell select + if (battle->ActiveHero().CanUseMagic()) { + ctrl->PushState(new SelectSpell(battle, this)); + } break; case AttackChoice::DEFEND: + battle->SetAttackType(AttackChoice::DEFEND); battle->NextHero(); break; case AttackChoice::IKARI: - // TODO: switch to ikari attack select + ctrl->PushState(new SelectIkari(battle, this)); break; case AttackChoice::ITEM: - // TODO: switch to item select + ctrl->PushState(new SelectItem(battle, this)); break; default: throw std::logic_error("selected invalid attack type"); } + } else if (input.JustPressed(Input::ACTION_B)) { + battle->SetAttackType(AttackChoice::UNDECIDED); + battle->PreviousHero(); + if (battle->BeforeFirstHero()) { + ctrl->ChangeState(new SelectMoveAction(battle)); + } } if (battle->AttackSelectionDone()) { @@ -101,7 +118,7 @@ void SelectAttackType::Render(SDL_Surface *screen) { void SelectAttackType::RenderMenu(SDL_Surface *screen, const Vector &offset) { Point position( (battle->BackgroundWidth() - battle->GetAttackTypeMenu().Width()) / 2, - (battle->BackgroundHeight() * 3 / 4) - (battle->GetAttackTypeMenu().Height() / 2)); + battle->BackgroundHeight() - battle->GetAttackTypeMenu().Height() - battle->GetAttackTypeMenu().Height() / 2); battle->GetAttackTypeMenu().Render(screen, position + offset); }