From: Daniel Karbach Date: Fri, 10 Aug 2012 15:16:58 +0000 (+0200) Subject: added target selection to select ikari state X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=c1443f347c55be69ad35d332ecb9f21dd85d965e;p=l2e.git added target selection to select ikari state --- diff --git a/src/battle/AttackChoice.h b/src/battle/AttackChoice.h index f365203..8cba235 100644 --- a/src/battle/AttackChoice.h +++ b/src/battle/AttackChoice.h @@ -11,6 +11,7 @@ #include "TargetSelection.h" namespace common { + class Ikari; class Item; class Spell; } diff --git a/src/battle/states/SelectIkari.cpp b/src/battle/states/SelectIkari.cpp index 85b61c7..c4fb500 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) { @@ -47,11 +53,28 @@ void SelectIkari::Resize(int width, int height) { void SelectIkari::HandleInput(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(), battle->Res().magicTargetCursor)); + } } } if (input.JustPressed(Input::ACTION_B)) {