monstersLayout->CalculatePositions(background->w, background->h, monsterPositions);
heroesLayout->CalculatePositions(background->w, background->h, heroesPositions);
for (int i(0); i < 4; ++i) {
- spellMenus[i] = res->spellMenuPrototype;
+ heroes[i].SpellMenu() = res->spellMenuPrototype;
LoadSpellMenu(i);
- ikariMenus[i] = res->ikariMenuPrototype;
+ heroes[i].IkariMenu() = res->ikariMenuPrototype;
LoadIkariMenu(i);
heroTags[i] = HeroTag(this, i);
smallHeroTags[i] = SmallHeroTag(this, i);
void BattleState::LoadSpellMenu(vector<Hero>::size_type index) {
assert(index >= 0 && index < 4);
- spellMenus[index].Clear();
- spellMenus[index].Reserve(HeroAt(index).Spells().size());
+ heroes[index].SpellMenu().Clear();
+ heroes[index].SpellMenu().Reserve(HeroAt(index).Spells().size());
for (vector<const Spell *>::const_iterator i(HeroAt(index).Spells().begin()), end(HeroAt(index).Spells().end()); i != end; ++i) {
bool enabled((*i)->CanUseInBattle() && (*i)->Cost() <= HeroAt(index).Mana());
- spellMenus[index].Add((*i)->Name(), *i, enabled, 0, (*i)->Cost());
+ heroes[index].SpellMenu().Add((*i)->Name(), *i, enabled, 0, (*i)->Cost());
}
}
void BattleState::LoadIkariMenu(vector<Hero>::size_type index) {
assert(index >= 0 && index < 4);
- ikariMenus[index].Clear();
- ikariMenus[index].Reserve(6);
+ heroes[index].IkariMenu().Clear();
+ heroes[index].IkariMenu().Reserve(6);
if (HeroAt(index).HasWeapon()) {
- ikariMenus[index].Add(
+ heroes[index].IkariMenu().Add(
HeroAt(index).Weapon()->Name(),
HeroAt(index).Weapon(),
HeroAt(index).Weapon()->HasIkari() && HeroAt(index).Weapon()->GetIkari()->Cost() <= HeroAt(index).IP(),
0,
HeroAt(index).Weapon()->HasIkari() ? HeroAt(index).Weapon()->GetIkari()->Name() : "");
} else {
- ikariMenus[index].Add(res->noEquipmentText, 0, false, res->weaponMenuIcon);
+ heroes[index].IkariMenu().Add(res->noEquipmentText, 0, false, res->weaponMenuIcon);
}
if (HeroAt(index).HasArmor()) {
- ikariMenus[index].Add(
+ heroes[index].IkariMenu().Add(
HeroAt(index).Armor()->Name(),
HeroAt(index).Armor(),
HeroAt(index).Armor()->HasIkari() && HeroAt(index).Armor()->GetIkari()->Cost() <= HeroAt(index).IP(),
0,
HeroAt(index).Armor()->HasIkari() ? HeroAt(index).Armor()->GetIkari()->Name() : "");
} else {
- ikariMenus[index].Add(res->noEquipmentText, 0, false, res->armorMenuIcon);
+ heroes[index].IkariMenu().Add(res->noEquipmentText, 0, false, res->armorMenuIcon);
}
if (HeroAt(index).HasShield()) {
- ikariMenus[index].Add(
+ heroes[index].IkariMenu().Add(
HeroAt(index).Shield()->Name(),
HeroAt(index).Shield(),
HeroAt(index).Shield()->HasIkari() && HeroAt(index).Shield()->GetIkari()->Cost() <= HeroAt(index).IP(),
0,
HeroAt(index).Shield()->HasIkari() ? HeroAt(index).Shield()->GetIkari()->Name() : "");
} else {
- ikariMenus[index].Add(res->noEquipmentText, 0, false, res->shieldMenuIcon);
+ heroes[index].IkariMenu().Add(res->noEquipmentText, 0, false, res->shieldMenuIcon);
}
if (HeroAt(index).HasHelmet()) {
- ikariMenus[index].Add(
+ heroes[index].IkariMenu().Add(
HeroAt(index).Helmet()->Name(),
HeroAt(index).Helmet(),
HeroAt(index).Helmet()->HasIkari() && HeroAt(index).Helmet()->GetIkari()->Cost() <= HeroAt(index).IP(),
0,
HeroAt(index).Helmet()->HasIkari() ? HeroAt(index).Helmet()->GetIkari()->Name() : "");
} else {
- ikariMenus[index].Add(res->noEquipmentText, 0, false, res->helmetMenuIcon);
+ heroes[index].IkariMenu().Add(res->noEquipmentText, 0, false, res->helmetMenuIcon);
}
if (HeroAt(index).HasRing()) {
- ikariMenus[index].Add(
+ heroes[index].IkariMenu().Add(
HeroAt(index).Ring()->Name(),
HeroAt(index).Ring(),
HeroAt(index).Ring()->HasIkari() && HeroAt(index).Ring()->GetIkari()->Cost() <= HeroAt(index).IP(),
0,
HeroAt(index).Ring()->HasIkari() ? HeroAt(index).Ring()->GetIkari()->Name() : "");
} else {
- ikariMenus[index].Add(res->noEquipmentText, 0, false, res->ringMenuIcon);
+ heroes[index].IkariMenu().Add(res->noEquipmentText, 0, false, res->ringMenuIcon);
}
if (HeroAt(index).HasJewel()) {
- ikariMenus[index].Add(
+ heroes[index].IkariMenu().Add(
HeroAt(index).Jewel()->Name(),
HeroAt(index).Jewel(),
HeroAt(index).Jewel()->HasIkari() && HeroAt(index).Jewel()->GetIkari()->Cost() <= HeroAt(index).IP(),
0,
HeroAt(index).Jewel()->HasIkari() ? HeroAt(index).Jewel()->GetIkari()->Name() : "");
} else {
- ikariMenus[index].Add(res->noEquipmentText, 0, false, res->jewelMenuIcon);
+ heroes[index].IkariMenu().Add(res->noEquipmentText, 0, false, res->jewelMenuIcon);
}
}
attackCursor = -1;
activeHero = -1;
for (int i(0); i < numHeroes; ++i) {
- attackChoices[i] = AttackChoice(this);
+ heroes[i].GetAttackChoice() = AttackChoice(this);
}
attackOrder.clear();
monsterAttacks.clear();
assert(screen);
for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
if (MonsterPositionOccupied(i)) {
- // TODO: better solution for running animations
if (monsters[i].GetAnimation().Running()) {
monsters[i].GetAnimation().DrawCenter(screen, monsterPositions[i] + offset);
} else {
#ifndef BATTLE_BATTLESTATE_H_
#define BATTLE_BATTLESTATE_H_
-#include "AttackChoice.h"
#include "AttackTypeMenu.h"
#include "Hero.h"
#include "HeroTag.h"
namespace battle {
+class AttackChoice;
class PartyLayout;
class Stats;
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::Spell *> &GetSpellMenu() { return heroes[activeHero].SpellMenu(); }
+ const graphics::Menu<const common::Spell *> &GetSpellMenu() const { return heroes[activeHero].SpellMenu(); }
+ graphics::Menu<const common::Item *> &GetIkariMenu() { return heroes[activeHero].IkariMenu(); }
+ const graphics::Menu<const common::Item *> &GetIkariMenu() const { return heroes[activeHero].IkariMenu(); }
graphics::Menu<const common::Item *> &GetItemMenu() { return itemMenu; }
const graphics::Menu<const common::Item *> &GetItemMenu() const { return itemMenu; }
bool HasChosenAttackType() const { return ActiveHeroAttackChoice().GetType() != AttackChoice::UNDECIDED; }
AttackChoice &ActiveHeroAttackChoice() { return AttackChoiceAt(activeHero); }
const AttackChoice &ActiveHeroAttackChoice() const { return AttackChoiceAt(activeHero); }
- AttackChoice &AttackChoiceAt(int index) { assert(index >= 0 && index < NumHeroes()); return attackChoices[index]; }
- const AttackChoice &AttackChoiceAt(int index) const { assert(index >= 0 && index < NumHeroes()); return attackChoices[index]; }
+ 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]; }
const AttackChoice &MonsterAttackChoiceAt(int index) const { assert(index >= 0 && index < MaxMonsters()); return monsterAttacks[index]; }
bool AttackSelectionDone() const { return activeHero >= numHeroes; }
std::vector<AttackChoice> monsterAttacks;
std::vector<Order> attackOrder;
Hero heroes[4];
- graphics::Menu<const common::Spell *> spellMenus[4];
graphics::Menu<const common::Item *> itemMenu;
- graphics::Menu<const common::Item *> ikariMenus[4];
HeroTag heroTags[4];
SmallHeroTag smallHeroTags[4];
geometry::Point<int> heroTagPositions[4];
geometry::Point<int> smallHeroTagPositions[4];
- AttackChoice attackChoices[4];
int numHeroes;
int activeHero;
int attackCursor;