+public:
+ const Resources &Res() const { return *res; }
+ AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
+ MoveMenu &GetMoveMenu() { return moveMenu; }
+
+ graphics::Menu<const common::Item *> &ItemMenu() { return itemMenu; }
+ const graphics::Menu<const common::Item *> &ItemMenu() const { return itemMenu; }
+
+ void NextHero();
+ bool BeforeFirstHero() const { return activeHero < 0; }
+ void PreviousHero();
+ void SwapHeroes(int lhs, int rhs);
+ Hero &ActiveHero() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero]; }
+ const Hero &ActiveHero() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero]; }
+
+ Hero &HeroAt(int index) { assert(index >= 0 && index < NumHeroes()); return heroes[index]; }
+ const Hero &HeroAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroes[index]; }
+ Monster &MonsterAt(int index) { assert(index >= 0 && index < NumHeroes()); return monsters[index]; }
+ const Monster &MonsterAt(int index) const { assert(index >= 0 && index < NumHeroes()); return monsters[index]; }
+
+ const HeroTag &HeroTagAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTags[index]; }
+ const geometry::Vector<int> &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; }
+
+ bool HasChosenAttackType() const { return ActiveHero().GetAttackChoice().GetType() != AttackChoice::UNDECIDED; }
+ bool AttackSelectionDone() const { return activeHero >= numHeroes; }
+
+ int NumHeroes() const { return numHeroes; }
+ int MaxHeroes() const { return 4; }
+ int MaxMonsters() const { return monsters.size(); }
+
+ bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; }
+ bool HeroPositionOccupied(int index) const { return index >= 0 && index < numHeroes; }
+
+ void SetRunaway() { ranAway = true; }
+
+ struct Order {
+ Order(int index, bool isMonster)
+ : index(index), isMonster(isMonster) { }
+ int index;
+ bool isMonster;
+ };
+
+ void CalculateAttackOrder();
+ void NextAttack();
+ bool AttacksFinished() const;
+ void CalculateDamage();
+ void ApplyDamage();
+ const Order &CurrentAttack() const { assert(attackCursor >= 0 && attackCursor < int(attackOrder.size())); return attackOrder[attackCursor]; };
+ AttackChoice &CurrentAttackAttackChoice();
+ void ClearAllAttacks();
+
+ bool Victory() const;
+ bool Defeat() const;
+
+public:
+ geometry::Vector<int> CalculateScreenOffset(SDL_Surface *screen) const {
+ return geometry::Vector<int>(
+ (screen->w - background->w) / 2,
+ (screen->h - background->h) / 2);
+ }
+ int Width() const { return background->w; }
+ int Height() const { return background->h; }
+ geometry::Vector<int> Size() const { return geometry::Vector<int>(Width(), Height()); }
+