Further implementation of types.

This commit is contained in:
2019-11-05 08:06:12 +01:00
parent 168e14d394
commit db2a577a85
8 changed files with 42 additions and 24 deletions

View File

@@ -1,5 +1,4 @@
#include "TurnHandler.hpp"
#include "../Models/Creature.hpp"
#include "../Models/Battle.hpp"
#include "../Models/ExecutingAttack.hpp"
#include "../../Core/Exceptions/NotImplementedException.hpp"
@@ -7,7 +6,9 @@
void CreatureLib::Battling::TurnHandler::RunTurn(CreatureLib::Battling::ChoiceQueue &queue) {
//HOOK: On Before Turn hook for all choices
while (queue.HasNext()){
ExecuteChoice(queue.Dequeue());
auto item = queue.Dequeue();
ExecuteChoice(item);
delete item;
}
}
@@ -38,14 +39,12 @@ void CreatureLib::Battling::TurnHandler::ExecuteChoice(const CreatureLib::Battli
switch (choiceKind){
case TurnChoiceKind::Pass: return;
case TurnChoiceKind::Attack:
return ExecuteAttackChoice(static_cast<const AttackTurnChoice*>(choice));
return ExecuteAttackChoice(dynamic_cast<const AttackTurnChoice*>(choice));
case TurnChoiceKind::Item:
case TurnChoiceKind::Switch:
case TurnChoiceKind::RunAway:
throw NotImplementedException();
}
delete choice;
}
void CreatureLib::Battling::TurnHandler::ExecuteAttackChoice(const CreatureLib::Battling::AttackTurnChoice *choice) {
@@ -100,6 +99,9 @@ void CreatureLib::Battling::TurnHandler::HandleAttackForTarget(CreatureLib::Batt
}
auto hit = targetData.GetHit(hitIndex);
//TODO: calculate data for hit
hit.SetEffectiveness(user->GetBattle()->GetLibrary()->GetTypeLibrary()->GetEffectiveness(hit.GetType(), target->GetTypes()));
if (attackData->GetCategory() == Library::AttackCategory::Status){
//HOOK: Status attack
}