AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
MoveMenu &GetMoveMenu() { return moveMenu; }
+ graphics::Menu<const common::Spell *> &GetSpellMenu() { return spellMenus[activeHero]; }
+ const graphics::Menu<const common::Spell *> &GetSpellMenu() const { return spellMenus[activeHero]; }
+ graphics::Menu<const common::Item *> &GetIkariMenu() { return ikariMenus[activeHero]; }
+ const graphics::Menu<const common::Item *> &GetIkariMenu() const { return ikariMenus[activeHero]; }
+ graphics::Menu<const common::Item *> &GetItemMenu() { return itemMenu; }
+ const graphics::Menu<const common::Item *> &GetItemMenu() const { return itemMenu; }
+
bool HasMoreHeroes() const { return activeHero < numHeroes; }
void NextHero() { ++activeHero; }
bool BeforeFirstHero() const { return activeHero < 0; }
void PreviousHero() { --activeHero; }
+ void SwapHeroes(int lhs, int rhs);
Hero &ActiveHero() { return heroes[activeHero]; }
const Hero &ActiveHero() const { return heroes[activeHero]; }
+
Hero &HeroAt(int index) { return heroes[index]; }
const Hero &HeroAt(int index) const { return heroes[index]; }
Monster &MonsterAt(std::vector<Monster>::size_type index) { return monsters[index]; }
const Monster &MonsterAt(std::vector<Monster>::size_type index) const { return monsters[index]; }
- void SwapHeroes(int lhs, int rhs);
- const HeroTag &ActiveHeroTag() const { return heroTags[activeHero]; }
+
const HeroTag &HeroTagAt(int index) const { return heroTags[index]; }
const geometry::Point<int> &HeroTagPositionAt(int index) const { return heroTagPositions[index]; }
+
bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
- void SetAttackType(AttackChoice::Type t) { attackChoices[activeHero].SetType(t); }
AttackChoice &ActiveHeroAttackChoice() { return attackChoices[activeHero]; }
const AttackChoice &ActiveHeroAttackChoice() const { return attackChoices[activeHero]; }
const AttackChoice &AttackChoiceAt(int index) const { return attackChoices[index]; }
- TargetSelection &ActiveHeroTargets() { return attackChoices[activeHero].Selection(); }
- const TargetSelection &ActiveHeroTargets() const { return attackChoices[activeHero].Selection(); }
bool AttackSelectionDone() const { return activeHero >= numHeroes; }
- graphics::Menu<const common::Spell *> &GetSpellMenu() { return spellMenus[activeHero]; }
- const graphics::Menu<const common::Spell *> &GetSpellMenu() const { return spellMenus[activeHero]; }
- graphics::Menu<const common::Item *> &GetIkariMenu() { return ikariMenus[activeHero]; }
- const graphics::Menu<const common::Item *> &GetIkariMenu() const { return ikariMenus[activeHero]; }
- graphics::Menu<const common::Item *> &GetItemMenu() { return itemMenu; }
- const graphics::Menu<const common::Item *> &GetItemMenu() const { return itemMenu; }
-
const std::vector<geometry::Point<int> > &MonsterPositions() const { return monsterPositions; }
bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; }
const std::vector<geometry::Point<int> > &HeroesPositions() const { return heroesPositions; }
}
void SelectAttackType::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroTargets().HasSelected()) {
- battle->SetAttackType(battle->GetAttackTypeMenu().Selected());
+ if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHeroAttackChoice().SetType(battle->GetAttackTypeMenu().Selected());
battle->NextHero();
}
if (battle->AttackSelectionDone()) {
switch (battle->GetAttackTypeMenu().Selected()) {
case AttackChoice::SWORD:
// TODO: detect single/multiple/all attack mode
- battle->ActiveHeroTargets().SetSingle();
- battle->ActiveHeroTargets().Reset();
- ctrl->PushState(new SelectTarget(battle, this, &battle->ActiveHeroTargets(), battle->Res().weaponTargetCursor));
+ battle->ActiveHeroAttackChoice().Selection().SetSingle();
+ battle->ActiveHeroAttackChoice().Selection().Reset();
+ ctrl->PushState(new SelectTarget(battle, this, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().weaponTargetCursor));
break;
case AttackChoice::MAGIC:
if (battle->ActiveHero().CanUseMagic()) {
}
break;
case AttackChoice::DEFEND:
- battle->SetAttackType(AttackChoice::DEFEND);
+ battle->ActiveHeroAttackChoice().SetType(AttackChoice::DEFEND);
battle->NextHero();
break;
case AttackChoice::IKARI:
}
void SelectIkari::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroTargets().HasSelected()) {
- battle->SetAttackType(AttackChoice::IKARI);
+ if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHeroAttackChoice().SetType(AttackChoice::IKARI);
battle->ActiveHeroAttackChoice().SetItem(battle->GetIkariMenu().Selected());
ctrl.PopState();
}
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetIkariMenu().SelectedIsEnabled() && battle->GetIkariMenu().Selected()->HasIkari()) {
const Ikari *ikari(battle->GetIkariMenu().Selected()->GetIkari());
- battle->ActiveHeroTargets().Reset();
+ battle->ActiveHeroAttackChoice().Selection().Reset();
if (ikari->GetTargetingMode().TargetsAlly()) {
- battle->ActiveHeroTargets().SelectHeroes();
+ battle->ActiveHeroAttackChoice().Selection().SelectHeroes();
} else {
- battle->ActiveHeroTargets().SelectEnemies();
+ battle->ActiveHeroAttackChoice().Selection().SelectEnemies();
}
if (ikari->GetTargetingMode().TargetsAll()) {
- battle->SetAttackType(AttackChoice::MAGIC);
+ battle->ActiveHeroAttackChoice().SetType(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();
+ battle->ActiveHeroAttackChoice().Selection().SetSingle();
} else {
- battle->ActiveHeroTargets().SetMultiple();
+ battle->ActiveHeroAttackChoice().Selection().SetMultiple();
}
- ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), ikari->IsMagical() ? battle->Res().magicTargetCursor : battle->Res().weaponTargetCursor));
+ ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), ikari->IsMagical() ? battle->Res().magicTargetCursor : battle->Res().weaponTargetCursor));
}
}
}
}
void SelectItem::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroTargets().HasSelected()) {
- battle->SetAttackType(AttackChoice::ITEM);
+ if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM);
battle->ActiveHeroAttackChoice().SetItem(battle->GetItemMenu().Selected());
ctrl.PopState();
}
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetItemMenu().SelectedIsEnabled()) {
const Item *item(battle->GetItemMenu().Selected());
- battle->ActiveHeroTargets().Reset();
+ battle->ActiveHeroAttackChoice().Selection().Reset();
if (item->GetTargetingMode().TargetsAlly()) {
- battle->ActiveHeroTargets().SelectHeroes();
+ battle->ActiveHeroAttackChoice().Selection().SelectHeroes();
} else {
- battle->ActiveHeroTargets().SelectEnemies();
+ battle->ActiveHeroAttackChoice().Selection().SelectEnemies();
}
if (item->GetTargetingMode().TargetsAll()) {
- battle->SetAttackType(AttackChoice::ITEM);
+ battle->ActiveHeroAttackChoice().SetType(AttackChoice::ITEM);
// TODO: remove item from inventory
battle->ActiveHeroAttackChoice().SetItem(item);
battle->NextHero();
ctrl->PopState();
} else {
if (item->GetTargetingMode().TargetsSingle()) {
- battle->ActiveHeroTargets().SetSingle();
+ battle->ActiveHeroAttackChoice().Selection().SetSingle();
} else {
- battle->ActiveHeroTargets().SetMultiple();
+ battle->ActiveHeroAttackChoice().Selection().SetMultiple();
}
- ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), battle->Res().itemTargetCursor));
+ ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().itemTargetCursor));
}
}
}
}
void SelectSpell::ResumeState(Application &ctrl, SDL_Surface *screen) {
- if (battle->ActiveHeroTargets().HasSelected()) {
- battle->SetAttackType(AttackChoice::MAGIC);
+ if (battle->ActiveHeroAttackChoice().Selection().HasSelected()) {
+ battle->ActiveHeroAttackChoice().SetType(AttackChoice::MAGIC);
battle->ActiveHeroAttackChoice().SetSpell(battle->GetSpellMenu().Selected());
ctrl.PopState();
}
if (input.JustPressed(Input::ACTION_A)) {
if (battle->GetSpellMenu().SelectedIsEnabled()) {
const Spell *spell(battle->GetSpellMenu().Selected());
- battle->ActiveHeroTargets().Reset();
+ battle->ActiveHeroAttackChoice().Selection().Reset();
if (spell->GetTargetingMode().TargetsAlly()) {
- battle->ActiveHeroTargets().SelectHeroes();
+ battle->ActiveHeroAttackChoice().Selection().SelectHeroes();
} else {
- battle->ActiveHeroTargets().SelectEnemies();
+ battle->ActiveHeroAttackChoice().Selection().SelectEnemies();
}
if (spell->GetTargetingMode().TargetsAll()) {
- battle->SetAttackType(AttackChoice::MAGIC);
+ battle->ActiveHeroAttackChoice().SetType(AttackChoice::MAGIC);
// TODO: remove item from inventory
battle->ActiveHeroAttackChoice().SetSpell(spell);
battle->NextHero();
ctrl->PopState();
} else {
if (spell->GetTargetingMode().TargetsSingle()) {
- battle->ActiveHeroTargets().SetSingle();
+ battle->ActiveHeroAttackChoice().Selection().SetSingle();
} else {
- battle->ActiveHeroTargets().SetMultiple();
+ battle->ActiveHeroAttackChoice().Selection().SetMultiple();
}
- ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroTargets(), battle->Res().magicTargetCursor));
+ ctrl->PushState(new SelectTarget(battle, parent, &battle->ActiveHeroAttackChoice().Selection(), battle->Res().magicTargetCursor));
}
}
}