More defensive programming.
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2020-08-30 13:14:33 +02:00
parent 32f75f4a47
commit 3233daf9ab
5 changed files with 60 additions and 25 deletions

View File

@@ -54,12 +54,12 @@ void Battle::CheckChoicesSetAndRun() {
for (auto choice : side->GetChoices()) {
AssertNotNull(choice)
if (choice->GetKind() == TurnChoiceKind::Attack) {
auto attack = ((AttackTurnChoice*)choice.get())->GetAttack();
auto attack = std::static_pointer_cast<AttackTurnChoice>(choice);
uint8_t uses = 1;
// HOOK: change number of uses needed.
if (attack->GetRemainingUses() < uses) {
if (attack->GetAttack()->GetRemainingUses() < uses) {
choice = std::shared_ptr<BaseTurnChoice>(_library->GetMiscLibrary()->ReplacementAttack(
choice->GetUser().GetRaw(), ((AttackTurnChoice*)choice.get())->GetTarget()));
choice->GetUser().GetRaw(), attack->GetTarget()));
}
// HOOK: Check if we need to change the move
}
@@ -74,7 +74,7 @@ void Battle::CheckChoicesSetAndRun() {
}
_currentTurn++;
try {
TurnOrdering::OrderChoices(choices, _random.GetRNG());
TurnOrdering::OrderChoices(choices);
} catch (const std::exception& e) {
THROW("Exception during turn ordering: '" << e.what() << "'.")
}