diff --git a/src/Battling/Flow/TurnHandler.cpp b/src/Battling/Flow/TurnHandler.cpp index ee6fb2a..14783d7 100644 --- a/src/Battling/Flow/TurnHandler.cpp +++ b/src/Battling/Flow/TurnHandler.cpp @@ -18,6 +18,8 @@ void TurnHandler::RunTurn(ArbUt::BorrowedPtr queue) { "Executing choice failed for choice by mon on side " << ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetSideIndex()) << " and index " << ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetCreatureIndex(item->GetUser())) + << ". Choice had choice kind " + << CreatureLib::Battling::TurnChoiceKindHelper::ToString(item->GetKind()) << " " << " with message"); } queue->HasCompletedQueue = true; @@ -68,9 +70,11 @@ void TurnHandler::ExecuteAttackChoice(ArbUt::BorrowedPtr choic // TODO: Change attack } - auto target = choice->GetUser()->GetBattle()->GetCreature(choice->GetTarget()); - ArbUt::List> targets = TargetResolver::ResolveTargets( - choice->GetTarget(), choice->GetAttack()->GetAttack()->GetTarget(), choice->GetUser()->GetBattle()); + auto targetType = choice->GetAttack()->GetAttack()->GetTarget(); + ArbUt::List> targets; + try_creature(targets = + TargetResolver::ResolveTargets(choice->GetTarget(), targetType, choice->GetUser()->GetBattle()); + , "Exception during target determination: '" << e.what() << "'."); auto attack = ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript()); bool prevented = false; @@ -101,7 +105,9 @@ void TurnHandler::ExecuteAttackChoice(ArbUt::BorrowedPtr choic HOOK_LOCAL(OnBeforeAttack, attack, &attack); for (uint8_t i = 0; i < attack.GetTargetCount(); i++) { - HandleAttackForTarget(&attack, attack.GetTargets()[i]); + auto target = attack.GetTargets()[i]; + try_creature(HandleAttackForTarget(&attack, target), + "Exception occured during handling attack for target: '" << e.what() << "'."); } } diff --git a/src/Battling/TurnChoices/TurnChoiceKind.hpp b/src/Battling/TurnChoices/TurnChoiceKind.hpp index 1577c09..c358aa6 100644 --- a/src/Battling/TurnChoices/TurnChoiceKind.hpp +++ b/src/Battling/TurnChoices/TurnChoiceKind.hpp @@ -4,6 +4,6 @@ #include namespace CreatureLib::Battling { - enum class TurnChoiceKind : uint8_t { Pass, Attack, Item, Switch, Flee }; + ENUM(TurnChoiceKind, uint8_t, Pass, Attack, Item, Switch, Flee); } #endif // CREATURELIB_TURNCHOICEKIND_HPP