X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.h;h=525889591d5847e8088e0c5753d28f67e6d7cfc6;hb=a3ba4dc677ad7c92eeb78b20b642241563605c9d;hp=0f51f237cd2a47138ac222127f269a15f477aca8;hpb=cc3d698b8c1ad09d7a3f9e3f28bc84e0ac1735ea;p=l2e.git diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 0f51f23..5258895 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -3,6 +3,7 @@ #include "fwd.h" #include "AttackTypeMenu.h" +#include "Capsule.h" #include "Hero.h" #include "HeroTag.h" #include "Monster.h" @@ -14,7 +15,7 @@ #include "../common/GameConfig.h" #include "../common/fwd.h" #include "../common/Stats.h" -#include "../geometry/Vector.h" +#include "../math/Vector.h" #include "../graphics/Animation.h" #include "../graphics/fwd.h" #include "../graphics/Menu.h" @@ -47,6 +48,7 @@ public: public: void AddMonster(const Monster &); void AddHero(const Hero &); + void SetCapsule(const Capsule &); public: virtual void HandleEvents(const app::Input &); @@ -74,7 +76,9 @@ public: const Monster &MonsterAt(int index) const { assert(index >= 0 && index < NumHeroes()); return monsters[index]; } const HeroTag &HeroTagAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTags[index]; } - const geometry::Vector &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; } + const math::Vector &HeroTagPositionAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroTagPositions[index]; } + + Capsule &GetCapsule() { return capsule; } bool HasChosenAttackType() const { return ActiveHero().GetAttackChoice().GetType() != AttackChoice::UNDECIDED; } bool AttackSelectionDone() const { return activeHero >= numHeroes; } @@ -89,10 +93,20 @@ public: void SetRunaway() { ranAway = true; } struct Order { - Order(int index, bool isMonster) - : index(index), isMonster(isMonster) { } + enum Performer { + HERO, + CAPSULE, + MONSTER, + }; + Order(Performer by, int index = 0) + : index(index), by(by) { } + AttackChoice &GetAttackChoice(BattleState &) const; + common::Stats &GetStats(BattleState &) const; + bool IsHero() const { return by == HERO; } + bool IsCapsule() const { return by == CAPSULE; } + bool IsMonster() const { return by == MONSTER; } int index; - bool isMonster; + Performer by; }; void CalculateAttackOrder(); @@ -108,20 +122,21 @@ public: bool Defeat() const; public: - geometry::Vector CalculateScreenOffset(SDL_Surface *screen) const { - return geometry::Vector( + math::Vector CalculateScreenOffset(SDL_Surface *screen) const { + return math::Vector( (screen->w - background->w) / 2, (screen->h - background->h) / 2); } int Width() const { return background->w; } int Height() const { return background->h; } - geometry::Vector Size() const { return geometry::Vector(Width(), Height()); } + math::Vector Size() const { return math::Vector(Width(), Height()); } - 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); + void RenderBackground(SDL_Surface *screen, const math::Vector &offset); + void RenderMonsters(SDL_Surface *screen, const math::Vector &offset); + void RenderHeroes(SDL_Surface *screen, const math::Vector &offset); + void RenderCapsule(SDL_Surface *screen, const math::Vector &offset); + void RenderHeroTags(SDL_Surface *screen, const math::Vector &offset); + void RenderSmallHeroTags(SDL_Surface *screen, const math::Vector &offset); private: virtual void OnEnterState(SDL_Surface *screen); @@ -134,7 +149,8 @@ private: private: void LoadInventory(); - void DecideMonsterAttack(Monster &) const; + void DecideMonsterAttack(Monster &); + void DecideCapsuleAttack(); void CalculateDamage(const common::Stats &attackerStats, TargetSelection &targets) const; Uint16 CalculateDamage(const common::Stats &attacker, const common::Stats &defender) const; @@ -152,8 +168,9 @@ private: graphics::Menu itemMenu; HeroTag heroTags[4]; SmallHeroTag smallHeroTags[4]; - geometry::Vector heroTagPositions[4]; - geometry::Vector smallHeroTagPositions[4]; + math::Vector heroTagPositions[4]; + math::Vector smallHeroTagPositions[4]; + Capsule capsule; int numHeroes; int activeHero; int attackCursor;