#include "SelectAttackType.h"
#include "SelectMoveAction.h"
+#include "SelectTarget.h"
#include "../BattleState.h"
#include "../../app/Application.h"
#include "../../app/Input.h"
+#include "../../common/Spell.h"
#include "../../geometry/operators.h"
#include "../../geometry/Point.h"
#include "../../graphics/Frame.h"
using app::Application;
using app::Input;
+using common::Spell;
using geometry::Point;
using geometry::Vector;
using graphics::Frame;
}
void SelectSpell::ResumeState(Application &ctrl, SDL_Surface *screen) {
-
+ if (battle->ActiveHeroTargets().HasSelected()) {
+ ctrl.PopState();
+ }
}
void SelectSpell::PauseState(Application &ctrl, SDL_Surface *screen) {
void SelectSpell::HandleInput(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
- // TODO: switch to target select
if (battle->GetSpellMenu().SelectedIsEnabled()) {
- battle->SetAttackType(AttackChoice::MAGIC);
- battle->NextHero();
- ctrl->PopState();
+ const Spell *spell(battle->GetSpellMenu().Selected());
+ battle->ActiveHeroTargets().Reset();
+ if (spell->GetTargetingMode().TargetsAlly()) {
+ battle->ActiveHeroTargets().SelectHeroes();
+ } else {
+ battle->ActiveHeroTargets().SelectEnemies();
+ }
+ if (spell->GetTargetingMode().TargetsAll()) {
+ battle->SetAttackType(AttackChoice::MAGIC);
+ // TODO: remove item from inventory
+ battle->ActiveHeroAttackChoice().SetSpell(spell);
+ battle->NextHero();
+ ctrl->PopState();
+ } else {
+ if (spell->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)) {
SDL_Surface *targetingIconsImg(IMG_Load("test-data/targeting-icons.png"));
Sprite weaponTargetCursor(targetingIconsImg, 32, 32);
+ Sprite magicTargetCursor(targetingIconsImg, 32, 32, 0, 32);
Sprite itemTargetCursor(targetingIconsImg, 32, 32, 0, 64);
battleRes.weaponTargetCursor = &weaponTargetCursor;
// TODO: add image for magic targeting cursor
- battleRes.magicTargetCursor = &weaponTargetCursor;
+ battleRes.magicTargetCursor = &magicTargetCursor;
// TODO: add image for item targeting cursor
battleRes.itemTargetCursor = &itemTargetCursor;
strongSpell.SetName("Strong");
strongSpell.SetCost(3);
strongSpell.SetUsableInBattle();
+ strongSpell.GetTargetingMode().TargetMultipleAllies();
maxim.AddSpell(&strongSpell);
selan.AddSpell(&strongSpell);
Spell strongerSpell;
strongerSpell.SetName("Stronger");
strongerSpell.SetCost(8);
strongerSpell.SetUsableInBattle();
+ strongerSpell.GetTargetingMode().TargetMultipleAllies();
maxim.AddSpell(&strongerSpell);
selan.AddSpell(&strongerSpell);
Spell championSpell;
championSpell.SetName("Champion");
championSpell.SetCost(16);
championSpell.SetUsableInBattle();
+ championSpell.GetTargetingMode().TargetMultipleAllies();
maxim.AddSpell(&championSpell);
selan.AddSpell(&championSpell);
Spell rallySpell;
rallySpell.SetName("Rally");
rallySpell.SetCost(10);
rallySpell.SetUsableInBattle();
+ rallySpell.GetTargetingMode().TargetMultipleAllies();
maxim.AddSpell(&rallySpell);
selan.AddSpell(&rallySpell);
Spell escapeSpell;
valorSpell.SetName("Valor");
valorSpell.SetCost(30);
valorSpell.SetUsableInBattle();
+ valorSpell.GetTargetingMode().TargetMultipleAllies();
maxim.AddSpell(&valorSpell);
selan.AddSpell(&valorSpell);
battleRes.spellMenuHeadline = "Please choose a spell.";
battleRes.spellMenuPrototype = Menu<const Spell *>(&normalFont, &disabledFont, &handCursorSprite, 9, 6, 8, 0, 2, 32, 2, ':');
- battleRes.spellMenuPrototype.Add("Poison : 2", 0);
- battleRes.spellMenuPrototype.Add("Warp : 8", 0, false);
- battleRes.spellMenuPrototype.Add("Release : 2", 0);
- battleRes.spellMenuPrototype.Add("Waken : 4", 0);
- battleRes.spellMenuPrototype.Add("Light : 0", 0, false);
- battleRes.spellMenuPrototype.Add("Fake : 4", 0);
- battleRes.spellMenuPrototype.Add("Trick : 5", 0);
- battleRes.spellMenuPrototype.Add("Flash : 5", 0);
- battleRes.spellMenuPrototype.Add("Fireball : 6", 0);
- battleRes.spellMenuPrototype.Add("Vortex : 7", 0);
- battleRes.spellMenuPrototype.Add("Blizzard : 8", 0);
- battleRes.spellMenuPrototype.Add("Spark : 3", 0);
SDL_Surface *itemIcons(IMG_Load("test-data/item-icons.png"));
Sprite potionIcon(itemIcons, 16, 16);