X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FSelectIkari.cpp;h=adeafb29fd7ca5ebfefe6825024e3867eb1aea5f;hb=923422e6a71f57b8fa24b826d1e2914faa144081;hp=3c11164ffcb8ede50fdba1c53c9661cb89c79734;hpb=b782e097508340f375a06f0f293775eb86c3df9c;p=l2e.git diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index 3c11164..adeafb2 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,9 @@ void SelectIkari::ExitState(Application &c, SDL_Surface *screen) { } void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) { - + if (battle->ActiveHeroTargets().HasSelected()) { + ctrl.PopState(); + } } void SelectIkari::PauseState(Application &ctrl, SDL_Surface *screen) { @@ -45,12 +51,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->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)) {