#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;
, numHeroes(0)
, activeHero(-1)
, attackCursor(-1)
+ , expReward(0)
+ , goldReward(0)
, ranAway(false) { assert(background && res); }
public:
virtual void UpdateWorld(float deltaT);
virtual void Render(SDL_Surface *);
+ // TODO: turn this mess into a well stuctured interface
public:
const Resources &Res() const { return *res; }
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() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); }
+ const graphics::Menu<const common::Spell *> &GetSpellMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); }
+ graphics::Menu<const common::Item *> &GetIkariMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); }
+ const graphics::Menu<const common::Item *> &GetIkariMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); }
graphics::Menu<const common::Item *> &GetItemMenu() { return itemMenu; }
const graphics::Menu<const common::Item *> &GetItemMenu() const { return itemMenu; }
void NextHero();
bool BeforeFirstHero() const { return activeHero < 0; }
- void PreviousHero() { --activeHero; }
+ void PreviousHero();
void SwapHeroes(int lhs, int rhs);
- Hero &ActiveHero() { return heroes[activeHero]; }
- const Hero &ActiveHero() const { return heroes[activeHero]; }
+ 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]; }
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; }
int NumHeroes() const { return numHeroes; }
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;
void RenderSmallHeroTags(SDL_Surface *screen, const geometry::Vector<int> &offset);
private:
- void LoadSpellMenu(std::vector<Hero>::size_type heroIndex);
- void LoadIkariMenu(std::vector<Hero>::size_type heroIndex);
void LoadInventory();
Uint16 CalculateDamage(const Stats &attacker, const Stats &defender) const;
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;
+ int expReward;
+ int goldReward;
bool ranAway;
};