X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=7d65c14a23d8a1d08890ac0d7c52a4512351287c;hb=51c5ffb4958968827b93624f7849c1b7d3a1eacb;hp=cfec6129a8cb0f47e81589e689a5182280f6a34e;hpb=e27fcf693589ede18b753d5f64f9dfecfe6344bd;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index cfec612..7d65c14 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -15,9 +15,11 @@ #include "Monster.h" #include "MoveMenu.h" #include "Resources.h" +#include "SmallHeroTag.h" #include "../app/State.h" #include "../geometry/Point.h" #include "../geometry/Vector.h" +#include "../graphics/Animation.h" #include "../graphics/Menu.h" #include @@ -53,6 +55,7 @@ public: , moveMenu(res->moveIcons) , numHeroes(0) , activeHero(-1) + , attackCursor(-1) , ranAway(false) { } public: @@ -83,8 +86,7 @@ public: graphics::Menu &GetItemMenu() { return itemMenu; } const graphics::Menu &GetItemMenu() const { return itemMenu; } - bool HasMoreHeroes() const { return activeHero < numHeroes; } - void NextHero() { ++activeHero; } + void NextHero(); bool BeforeFirstHero() const { return activeHero < 0; } void PreviousHero() { --activeHero; } void SwapHeroes(int lhs, int rhs); @@ -93,8 +95,8 @@ public: Hero &HeroAt(int index) { return heroes[index]; } const Hero &HeroAt(int index) const { return heroes[index]; } - Monster &MonsterAt(std::vector::size_type index) { return monsters[index]; } - const Monster &MonsterAt(std::vector::size_type index) const { return monsters[index]; } + Monster &MonsterAt(int index) { return monsters[index]; } + const Monster &MonsterAt(int index) const { return monsters[index]; } const HeroTag &HeroTagAt(int index) const { return heroTags[index]; } const geometry::Point &HeroTagPositionAt(int index) const { return heroTagPositions[index]; } @@ -102,33 +104,53 @@ 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; } + int NumHeroes() const { return numHeroes; } + int MaxHeroes() const { return 4; } + int MaxMonsters() const { return monsters.size(); } + const std::vector > &MonsterPositions() const { return monsterPositions; } bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; } const std::vector > &HeroesPositions() const { return heroesPositions; } - bool HeroPositionOccupied(int index) { return index >= 0 && index < numHeroes; } - int NumHeroes() const { return numHeroes; } - std::vector &Monsters() { return monsters; } - const std::vector &Monsters() const { return monsters; } + 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); void RenderHeroes(SDL_Surface *screen, const geometry::Vector &offset); void RenderHeroTags(SDL_Surface *screen, const geometry::Vector &offset); + void RenderSmallHeroTags(SDL_Surface *screen, const geometry::Vector &offset); private: void LoadSpellMenu(std::vector::size_type heroIndex); @@ -146,15 +168,20 @@ 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; graphics::Menu ikariMenus[4]; HeroTag heroTags[4]; + SmallHeroTag smallHeroTags[4]; geometry::Point heroTagPositions[4]; + geometry::Point smallHeroTagPositions[4]; AttackChoice attackChoices[4]; int numHeroes; int activeHero; + int attackCursor; bool ranAway; };