X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=578098fa40f4d6c86c1ee41628be71ba231314fe;hb=591ecc2d7ecb0b41144be9b64c09801ac0a28131;hp=736e2c17ad3f15dbf733220728b53fce1df6a5c8;hpb=e559a146d268996a3367e370213b09a3b190e0bc;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 736e2c1..578098f 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -41,6 +41,7 @@ namespace graphics { namespace battle { class PartyLayout; +class Stats; class BattleState : public app::State { @@ -55,6 +56,7 @@ public: , moveMenu(res->moveIcons) , numHeroes(0) , activeHero(-1) + , attackCursor(-1) , ranAway(false) { } public: @@ -97,15 +99,13 @@ public: Monster &MonsterAt(int index) { return monsters[index]; } const Monster &MonsterAt(int index) const { return monsters[index]; } - graphics::Animation &HeroAnimationAt(int index) { return heroAnimations[index]; } - const graphics::Animation &HeroAnimationAt(int index) const { return heroAnimations[index]; } - const HeroTag &HeroTagAt(int index) const { return heroTags[index]; } const geometry::Point &HeroTagPositionAt(int index) const { return heroTagPositions[index]; } 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; } @@ -119,16 +119,33 @@ public: 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 CalculateScreenOffset(SDL_Surface *screen) const { return geometry::Vector( (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 &offset); void RenderMonsters(SDL_Surface *screen, const geometry::Vector &offset); @@ -141,6 +158,8 @@ private: void LoadIkariMenu(std::vector::size_type heroIndex); void LoadInventory(); + Uint16 CalculateDamage(const Stats &attacker, const Stats &defender) const; + private: SDL_Surface *background; const PartyLayout *monstersLayout; @@ -152,8 +171,9 @@ private: std::vector > monsterPositions; std::vector > heroesPositions; std::vector monsters; + std::vector monsterAttacks; + std::vector attackOrder; Hero heroes[4]; - graphics::Animation heroAnimations[4]; graphics::Menu spellMenus[4]; graphics::Menu itemMenu; graphics::Menu ikariMenus[4]; @@ -164,6 +184,7 @@ private: AttackChoice attackChoices[4]; int numHeroes; int activeHero; + int attackCursor; bool ranAway; };