X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=578098fa40f4d6c86c1ee41628be71ba231314fe;hb=591ecc2d7ecb0b41144be9b64c09801ac0a28131;hp=3acc0b7699c79dd9ffeaef66c686d263c2a4d29e;hpb=8f6a2452408f4ae35396cd7008a6fab0ecb03a46;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 3acc0b7..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: @@ -103,6 +105,7 @@ 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; } @@ -116,7 +119,6 @@ public: bool HeroPositionOccupied(int index) const { return index >= 0 && index < numHeroes; } void SetRunaway() { ranAway = true; } - void ClearAllAttacks(); struct Order { Order(int index, bool isMonster) @@ -125,7 +127,16 @@ public: bool isMonster; }; - void WriteOrder(std::vector &); + 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 { @@ -147,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; @@ -158,6 +171,8 @@ private: std::vector > monsterPositions; std::vector > heroesPositions; std::vector monsters; + std::vector monsterAttacks; + std::vector attackOrder; Hero heroes[4]; graphics::Menu spellMenus[4]; graphics::Menu itemMenu; @@ -169,6 +184,7 @@ private: AttackChoice attackChoices[4]; int numHeroes; int activeHero; + int attackCursor; bool ranAway; };