More work on basic turn layout.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,14 +1,40 @@
|
||||
#include "TurnHandler.hpp"
|
||||
#include "../Models/Creature.hpp"
|
||||
#include "../Models/Battle.hpp"
|
||||
#include "../../Core/Exceptions/NotImplementedException.hpp"
|
||||
|
||||
void CreatureLib::Battling::TurnHandler::RunTurn(CreatureLib::Battling::ChoiceQueue &queue) {
|
||||
//HOOK: On Before Turn hook for all choices
|
||||
while (queue.HasNext()){
|
||||
ExecuteChoice(queue.Dequeue());
|
||||
}
|
||||
}
|
||||
|
||||
void CreatureLib::Battling::TurnHandler::ExecuteChoice(const CreatureLib::Battling::BaseTurnChoice *choice) {
|
||||
switch (choice->GetKind()){
|
||||
if (choice == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto choiceKind = choice->GetKind();
|
||||
if (choiceKind == TurnChoiceKind::Pass) {
|
||||
return;
|
||||
}
|
||||
auto user = choice->GetUser();
|
||||
// If the user is fainted, we don't want to execute its choice.
|
||||
if (user->IsFainted()){
|
||||
return;
|
||||
}
|
||||
auto battle = user->GetBattle();
|
||||
// If the user is not in the field, we don't want to execute its choice.
|
||||
if (!battle->CreatureInField(user)){
|
||||
return;
|
||||
}
|
||||
// If the choice is not valid, we don't want to execute it.
|
||||
if (!battle->CanUse(choice)){
|
||||
return;
|
||||
}
|
||||
|
||||
switch (choiceKind){
|
||||
case TurnChoiceKind::Pass: return;
|
||||
case TurnChoiceKind::Attack:
|
||||
return ExecuteAttackChoice(static_cast<const AttackTurnChoice*>(choice));
|
||||
@@ -17,9 +43,15 @@ void CreatureLib::Battling::TurnHandler::ExecuteChoice(const CreatureLib::Battli
|
||||
case TurnChoiceKind::RunAway:
|
||||
throw NotImplementedException();
|
||||
}
|
||||
|
||||
delete choice;
|
||||
}
|
||||
|
||||
void CreatureLib::Battling::TurnHandler::ExecuteAttackChoice(const CreatureLib::Battling::AttackTurnChoice *choice) {
|
||||
//HOOK: Change attack
|
||||
|
||||
//HOOK: Prevent attack
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user