From ffba5fb24c9b6ebb49b5408e337195aa1aabc181 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 31 Oct 2019 13:13:36 +0100 Subject: [PATCH] Basic layout for turn execution --- src/Battling/Flow/TurnHandler.cpp | 19 +++++++++++++++++++ src/Battling/Flow/TurnHandler.hpp | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/Battling/Flow/TurnHandler.cpp b/src/Battling/Flow/TurnHandler.cpp index 366e139..02969de 100644 --- a/src/Battling/Flow/TurnHandler.cpp +++ b/src/Battling/Flow/TurnHandler.cpp @@ -1,5 +1,24 @@ #include "TurnHandler.hpp" void CreatureLib::Battling::TurnHandler::RunTurn(CreatureLib::Battling::ChoiceQueue &queue) { + while (queue.HasNext()){ + ExecuteChoice(queue.Dequeue()); + } +} + +void CreatureLib::Battling::TurnHandler::ExecuteChoice(const CreatureLib::Battling::BaseTurnChoice *choice) { + switch (choice->GetKind()){ + case TurnChoiceKind::Pass: return; + case TurnChoiceKind::Attack: + return ExecuteAttackChoice(static_cast(choice)); + case TurnChoiceKind::Item: + case TurnChoiceKind::Switch: + case TurnChoiceKind::RunAway: + throw "Not implemented"; + } +} + +void CreatureLib::Battling::TurnHandler::ExecuteAttackChoice(const CreatureLib::Battling::AttackTurnChoice *choice) { } + diff --git a/src/Battling/Flow/TurnHandler.hpp b/src/Battling/Flow/TurnHandler.hpp index 0c71b88..81db395 100644 --- a/src/Battling/Flow/TurnHandler.hpp +++ b/src/Battling/Flow/TurnHandler.hpp @@ -2,11 +2,15 @@ #define CREATURELIB_TURNHANDLER_HPP #include "ChoiceQueue.hpp" +#include "../TurnChoices/AttackTurnChoice.hpp" namespace CreatureLib::Battling { class Battle; class TurnHandler { + static void ExecuteChoice(const BaseTurnChoice* choice); + + static void ExecuteAttackChoice(const AttackTurnChoice* choice); public: static void RunTurn(ChoiceQueue& queue); };