, moveMenu(res->moveIcons)
, numHeroes(0)
, activeHero(-1)
+ , attackCursor(-1)
, ranAway(false) { }
public:
bool HasChosenAttackType() const { return attackChoices[activeHero].GetType() != AttackChoice::UNDECIDED; }
AttackChoice &ActiveHeroAttackChoice() { return attackChoices[activeHero]; }
const AttackChoice &ActiveHeroAttackChoice() const { return attackChoices[activeHero]; }
+ AttackChoice &AttackChoiceAt(int index) { return attackChoices[index]; }
const AttackChoice &AttackChoiceAt(int index) const { return attackChoices[index]; }
bool AttackSelectionDone() const { return activeHero >= numHeroes; }
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 { return attackCursor >= int(attackOrder.size()); }
+ void CalculateDamage();
+ void ApplyDamage();
+ const Order &CurrentAttack() const { return attackOrder[attackCursor]; };
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 BackgroundWidth() const { return background->w; }
- int BackgroundHeight() const { return background->h; }
+ int Width() const { return background->w; }
+ int Height() const { return background->h; }
void RenderBackground(SDL_Surface *screen, const geometry::Vector<int> &offset);
void RenderMonsters(SDL_Surface *screen, const geometry::Vector<int> &offset);
std::vector<geometry::Point<int> > monsterPositions;
std::vector<geometry::Point<int> > heroesPositions;
std::vector<Monster> monsters;
+ std::vector<AttackChoice> monsterAttacks;
+ std::vector<Order> attackOrder;
Hero heroes[4];
graphics::Menu<const common::Spell *> spellMenus[4];
graphics::Menu<const common::Item *> itemMenu;
AttackChoice attackChoices[4];
int numHeroes;
int activeHero;
+ int attackCursor;
bool ranAway;
};