Further clearer error handling.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b56226076e
commit
5a41208fdb
|
@ -18,6 +18,8 @@ void TurnHandler::RunTurn(ArbUt::BorrowedPtr<ChoiceQueue> queue) {
|
||||||
"Executing choice failed for choice by mon on side "
|
"Executing choice failed for choice by mon on side "
|
||||||
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetSideIndex()) << " and index "
|
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetSideIndex()) << " and index "
|
||||||
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetCreatureIndex(item->GetUser()))
|
<< ((uint32_t)item.get()->GetUser()->GetBattleSide()->GetCreatureIndex(item->GetUser()))
|
||||||
|
<< ". Choice had choice kind "
|
||||||
|
<< CreatureLib::Battling::TurnChoiceKindHelper::ToString(item->GetKind()) << " "
|
||||||
<< " with message");
|
<< " with message");
|
||||||
}
|
}
|
||||||
queue->HasCompletedQueue = true;
|
queue->HasCompletedQueue = true;
|
||||||
|
@ -68,9 +70,11 @@ void TurnHandler::ExecuteAttackChoice(ArbUt::BorrowedPtr<AttackTurnChoice> choic
|
||||||
// TODO: Change attack
|
// TODO: Change attack
|
||||||
}
|
}
|
||||||
|
|
||||||
auto target = choice->GetUser()->GetBattle()->GetCreature(choice->GetTarget());
|
auto targetType = choice->GetAttack()->GetAttack()->GetTarget();
|
||||||
ArbUt::List<ArbUt::BorrowedPtr<Creature>> targets = TargetResolver::ResolveTargets(
|
ArbUt::List<ArbUt::BorrowedPtr<Creature>> targets;
|
||||||
choice->GetTarget(), choice->GetAttack()->GetAttack()->GetTarget(), choice->GetUser()->GetBattle());
|
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());
|
auto attack = ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript());
|
||||||
bool prevented = false;
|
bool prevented = false;
|
||||||
|
@ -101,7 +105,9 @@ void TurnHandler::ExecuteAttackChoice(ArbUt::BorrowedPtr<AttackTurnChoice> choic
|
||||||
HOOK_LOCAL(OnBeforeAttack, attack, &attack);
|
HOOK_LOCAL(OnBeforeAttack, attack, &attack);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < attack.GetTargetCount(); i++) {
|
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() << "'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,6 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace CreatureLib::Battling {
|
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
|
#endif // CREATURELIB_TURNCHOICEKIND_HPP
|
||||||
|
|
Loading…
Reference in New Issue