const HeroTag &HeroTagAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTags[index]; }
const geometry::Point<int> &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; }
- bool HasChosenAttackType() const { return ActiveHeroAttackChoice().GetType() != AttackChoice::UNDECIDED; }
- AttackChoice &ActiveHeroAttackChoice() { return AttackChoiceAt(activeHero); }
- const AttackChoice &ActiveHeroAttackChoice() const { return AttackChoiceAt(activeHero); }
+ bool HasChosenAttackType() const { return ActiveHero().GetAttackChoice().GetType() != AttackChoice::UNDECIDED; }
AttackChoice &AttackChoiceAt(int index) { assert(index >= 0 && index < NumHeroes()); return heroes[index].GetAttackChoice(); }
const AttackChoice &AttackChoiceAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroes[index].GetAttackChoice(); }
AttackChoice &MonsterAttackChoiceAt(int index) { assert(index >= 0 && index < MaxMonsters()); return monsterAttacks[index]; }
}
void SelectAttackType::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
- battle->ActiveHeroAttackChoice().SetType(battle->GetAttackTypeMenu().Selected());
+ if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHero().GetAttackChoice().SetType(battle->GetAttackTypeMenu().Selected());
battle->NextHero();
}
if (battle->AttackSelectionDone()) {
switch (battle->GetAttackTypeMenu().Selected()) {
case AttackChoice::SWORD:
// TODO: detect single/multiple/all attack mode
- battle->ActiveHeroAttackChoice().Selection().SetSingle();
- battle->ActiveHeroAttackChoice().Selection().Reset();
- ctrl->PushState(new SelectTarget(battle, this, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().weaponTargetCursor));
+ battle->ActiveHero().GetAttackChoice().Selection().SetSingle();
+ battle->ActiveHero().GetAttackChoice().Selection().Reset();
+ ctrl->PushState(new SelectTarget(battle, this, &battle->ActiveHero().GetAttackChoice().Selection(), battle->Res().weaponTargetCursor));
break;
case AttackChoice::MAGIC:
if (battle->ActiveHero().CanUseMagic()) {
}
break;
case AttackChoice::DEFEND:
- battle->ActiveHeroAttackChoice().SetType(AttackChoice::DEFEND);
+ battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::DEFEND);
battle->NextHero();
break;
case AttackChoice::IKARI:
throw std::logic_error("selected invalid attack type");
}
} else if (input.JustPressed(Input::ACTION_B)) {
- battle->ActiveHeroAttackChoice().Reset();
+ battle->ActiveHero().GetAttackChoice().Reset();
battle->PreviousHero();
if (battle->BeforeFirstHero()) {
ctrl->ChangeState(new SelectMoveAction(battle));
} else {
- battle->ActiveHeroAttackChoice().Reset();
+ battle->ActiveHero().GetAttackChoice().Reset();
}
}
}
void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
- battle->ActiveHeroAttackChoice().SetType(AttackChoice::IKARI);
- battle->ActiveHeroAttackChoice().SetItem(battle->GetIkariMenu().Selected());
+ if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::IKARI);
+ battle->ActiveHero().GetAttackChoice().SetItem(battle->GetIkariMenu().Selected());
ctrl.PopState();
}
}
void SelectIkari::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetIkariMenu().SelectedIsEnabled() && battle->GetIkariMenu().Selected()->HasIkari()) {
+ AttackChoice &ac(battle->ActiveHero().GetAttackChoice());
const Ikari *ikari(battle->GetIkariMenu().Selected()->GetIkari());
- battle->ActiveHeroAttackChoice().Selection().Reset();
+ ac.Selection().Reset();
if (ikari->GetTargetingMode().TargetsAlly()) {
- battle->ActiveHeroAttackChoice().Selection().SelectHeroes();
+ ac.Selection().SelectHeroes();
} else {
- battle->ActiveHeroAttackChoice().Selection().SelectEnemies();
+ ac.Selection().SelectEnemies();
}
if (ikari->GetTargetingMode().TargetsAll()) {
- battle->ActiveHeroAttackChoice().SetType(AttackChoice::MAGIC);
+ ac.SetType(AttackChoice::MAGIC);
// TODO: remove item from inventory
- battle->ActiveHeroAttackChoice().SetItem(battle->GetIkariMenu().Selected());
+ ac.SetItem(battle->GetIkariMenu().Selected());
battle->NextHero();
ctrl->PopState();
} else {
if (ikari->GetTargetingMode().TargetsSingle()) {
- battle->ActiveHeroAttackChoice().Selection().SetSingle();
+ ac.Selection().SetSingle();
} else {
- battle->ActiveHeroAttackChoice().Selection().SetMultiple();
+ ac.Selection().SetMultiple();
}
- ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), ikari->IsMagical() ? battle->Res().magicTargetCursor : battle->Res().weaponTargetCursor));
+ ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), ikari->IsMagical() ? battle->Res().magicTargetCursor : battle->Res().weaponTargetCursor));
}
}
}
}
void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
- battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM);
- battle->ActiveHeroAttackChoice().SetItem(battle->GetItemMenu().Selected());
+ if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::ITEM);
+ battle->ActiveHero().GetAttackChoice().SetItem(battle->GetItemMenu().Selected());
ctrl.PopState();
}
}
void SelectItem::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetItemMenu().SelectedIsEnabled()) {
+ AttackChoice &ac(battle->ActiveHero().GetAttackChoice());
const Item *item(battle->GetItemMenu().Selected());
- battle->ActiveHeroAttackChoice().Selection().Reset();
+ ac.Selection().Reset();
if (item->GetTargetingMode().TargetsAlly()) {
- battle->ActiveHeroAttackChoice().Selection().SelectHeroes();
+ ac.Selection().SelectHeroes();
} else {
- battle->ActiveHeroAttackChoice().Selection().SelectEnemies();
+ ac.Selection().SelectEnemies();
}
if (item->GetTargetingMode().TargetsAll()) {
- battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM);
+ ac.SetType(AttackChoice::ITEM);
// TODO: remove item from inventory
- battle->ActiveHeroAttackChoice().SetItem(item);
+ ac.SetItem(item);
battle->NextHero();
ctrl->PopState();
} else {
if (item->GetTargetingMode().TargetsSingle()) {
- battle->ActiveHeroAttackChoice().Selection().SetSingle();
+ ac.Selection().SetSingle();
} else {
- battle->ActiveHeroAttackChoice().Selection().SetMultiple();
+ ac.Selection().SetMultiple();
}
- ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().itemTargetCursor));
+ ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor));
}
}
}
}
void SelectSpell::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
- battle->ActiveHeroAttackChoice().SetType(AttackChoice::MAGIC);
- battle->ActiveHeroAttackChoice().SetSpell(battle->GetSpellMenu().Selected());
+ if (battle->ActiveHero().GetAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHero().GetAttackChoice().SetType(AttackChoice::MAGIC);
+ battle->ActiveHero().GetAttackChoice().SetSpell(battle->GetSpellMenu().Selected());
ctrl.PopState();
}
}
void SelectSpell::HandleEvents(const Input &input) {
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetSpellMenu().SelectedIsEnabled()) {
+ AttackChoice &ac(battle->ActiveHero().GetAttackChoice());
const Spell *spell(battle->GetSpellMenu().Selected());
- battle->ActiveHeroAttackChoice().Selection().Reset();
+ ac.Selection().Reset();
if (spell->GetTargetingMode().TargetsAlly()) {
- battle->ActiveHeroAttackChoice().Selection().SelectHeroes();
+ ac.Selection().SelectHeroes();
} else {
- battle->ActiveHeroAttackChoice().Selection().SelectEnemies();
+ ac.Selection().SelectEnemies();
}
if (spell->GetTargetingMode().TargetsAll()) {
- battle->ActiveHeroAttackChoice().SetType(AttackChoice::MAGIC);
+ ac.SetType(AttackChoice::MAGIC);
// TODO: remove item from inventory
- battle->ActiveHeroAttackChoice().SetSpell(spell);
+ ac.SetSpell(spell);
battle->NextHero();
ctrl->PopState();
} else {
if (spell->GetTargetingMode().TargetsSingle()) {
- battle->ActiveHeroAttackChoice().Selection().SetSingle();
+ ac.Selection().SetSingle();
} else {
- battle->ActiveHeroAttackChoice().Selection().SetMultiple();
+ ac.Selection().SetMultiple();
}
- ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().magicTargetCursor));
+ ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().magicTargetCursor));
}
}
}