Further clearer error handling.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-07-31 10:45:20 +02:00
parent b56226076e
commit 5a41208fdb
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 11 additions and 5 deletions

View File

@ -18,6 +18,8 @@ void TurnHandler::RunTurn(ArbUt::BorrowedPtr<ChoiceQueue> 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<AttackTurnChoice> choic
// TODO: Change attack
}
auto target = choice->GetUser()->GetBattle()->GetCreature(choice->GetTarget());
ArbUt::List<ArbUt::BorrowedPtr<Creature>> targets = TargetResolver::ResolveTargets(
choice->GetTarget(), choice->GetAttack()->GetAttack()->GetTarget(), choice->GetUser()->GetBattle());
auto targetType = choice->GetAttack()->GetAttack()->GetTarget();
ArbUt::List<ArbUt::BorrowedPtr<Creature>> 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<AttackTurnChoice> 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() << "'.");
}
}

View File

@ -4,6 +4,6 @@
#include <cstdint>
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