X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectIkari.cpp;h=605ba2caef9ea52670ee5e898b4bea3bb29dab4a;hb=222167ba3722dc7f47ff7510006bd516e0010a50;hp=85b61c79d24443dc02be1396e07e7c81b39e06cc;hpb=536a8c96ebfec2a2b34f680d3d0b97db8e66d599;p=l2e.git diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index 85b61c7..605ba2c 100644 --- a/src/battle/states/SelectIkari.cpp +++ b/src/battle/states/SelectIkari.cpp @@ -8,15 +8,19 @@ #include "SelectIkari.h" #include "SelectAttackType.h" +#include "SelectTarget.h" #include "../BattleState.h" #include "../../app/Application.h" #include "../../app/Input.h" +#include "../../common/Ikari.h" +#include "../../common/Item.h" #include "../../geometry/Point.h" #include "../../geometry/operators.h" #include "../../graphics/Frame.h" using app::Application; using app::Input; +using common::Ikari; using geometry::Point; using geometry::Vector; using graphics::Frame; @@ -32,7 +36,11 @@ void SelectIkari::ExitState(Application &c, SDL_Surface *screen) { } void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) { - + if (battle->ActiveHeroTargets().HasSelected()) { + battle->SetAttackType(AttackChoice::IKARI); + battle->ActiveHeroAttackChoice().SetItem(battle->GetIkariMenu().Selected()); + ctrl.PopState(); + } } void SelectIkari::PauseState(Application &ctrl, SDL_Surface *screen) { @@ -45,13 +53,30 @@ void SelectIkari::Resize(int width, int height) { } -void SelectIkari::HandleInput(const Input &input) { +void SelectIkari::HandleEvents(const Input &input) { if (input.JustPressed(Input::ACTION_A)) { - // TODO: switch to target select - if (battle->GetIkariMenu().SelectedIsEnabled()) { - battle->SetAttackType(AttackChoice::IKARI); - battle->NextHero(); - ctrl->PopState(); + if (battle->GetIkariMenu().SelectedIsEnabled() && battle->GetIkariMenu().Selected()->HasIkari()) { + const Ikari *ikari(battle->GetIkariMenu().Selected()->GetIkari()); + battle->ActiveHeroTargets().Reset(); + if (ikari->GetTargetingMode().TargetsAlly()) { + battle->ActiveHeroTargets().SelectHeroes(); + } else { + battle->ActiveHeroTargets().SelectEnemies(); + } + if (ikari->GetTargetingMode().TargetsAll()) { + battle->SetAttackType(AttackChoice::MAGIC); + // TODO: remove item from inventory + battle->ActiveHeroAttackChoice().SetItem(battle->GetIkariMenu().Selected()); + battle->NextHero(); + ctrl->PopState(); + } else { + if (ikari->GetTargetingMode().TargetsSingle()) { + battle->ActiveHeroTargets().SetSingle(); + } else { + battle->ActiveHeroTargets().SetMultiple(); + } + ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), ikari->IsMagical() ? battle->Res().magicTargetCursor : battle->Res().weaponTargetCursor)); + } } } if (input.JustPressed(Input::ACTION_B)) {