#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;
}
void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) {
-
+ if (battle->ActiveHeroTargets().HasSelected()) {
+ ctrl.PopState();
+ }
}
void SelectIkari::PauseState(Application &ctrl, SDL_Surface *screen) {
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)) {