Several additional checks to ensure battle does not finish turn when ended.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
fd1c6e9a0a
commit
add77325a4
|
@ -20,12 +20,15 @@ void TurnHandler::RunTurn(ArbUt::BorrowedPtr<ChoiceQueue> queue) {
|
|||
}
|
||||
|
||||
void TurnHandler::ExecuteChoice(ArbUt::BorrowedPtr<BaseTurnChoice> choice) {
|
||||
AssertNotNull(choice);
|
||||
AssertNotNull(choice)
|
||||
auto choiceKind = choice->GetKind();
|
||||
if (choiceKind == TurnChoiceKind::Pass) {
|
||||
return;
|
||||
}
|
||||
auto user = choice->GetUser();
|
||||
AssertNotNull(user)
|
||||
if (user->GetBattle()->HasEnded())
|
||||
return;
|
||||
// If the user is fainted, we don't want to execute its choice.
|
||||
if (user->IsFainted()) {
|
||||
return;
|
||||
|
@ -100,6 +103,8 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
|||
auto user = attack->GetUser();
|
||||
AssertNotNull(user)
|
||||
AssertNotNull(target)
|
||||
if (user->GetBattle()->HasEnded())
|
||||
return;
|
||||
|
||||
auto targetSource = target;
|
||||
auto userSource = attack;
|
||||
|
@ -130,6 +135,8 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
|||
auto& dmgLibrary = library->GetDamageLibrary();
|
||||
auto hitIterator = attack->GetTargetIteratorBegin(target.GetRaw());
|
||||
for (uint8_t hitIndex = 0; hitIndex < numberOfHits; hitIndex++) {
|
||||
if (user->GetBattle()->HasEnded())
|
||||
return;
|
||||
if (user->IsFainted()) {
|
||||
break;
|
||||
}
|
||||
|
@ -170,7 +177,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
|||
if (damage > 0) {
|
||||
target->Damage(damage, DamageSource::AttackDamage);
|
||||
|
||||
if (attackData->HasSecondaryEffect()) {
|
||||
if (attackData->HasSecondaryEffect() && !user->IsFainted()) {
|
||||
bool preventSecondary = false;
|
||||
HOOK(PreventSecondaryEffects, targetSource, attack, target.GetRaw(), hitIndex, &preventSecondary);
|
||||
if (!preventSecondary) {
|
||||
|
|
|
@ -101,6 +101,9 @@ bool Battle::CanSlotBeFilled(uint8_t side, uint8_t index) const {
|
|||
}
|
||||
|
||||
void Battle::ValidateBattleState() {
|
||||
if (_hasEnded) {
|
||||
return;
|
||||
}
|
||||
bool survivingSideExists = false;
|
||||
uint8_t winningSide = 255;
|
||||
for (uint8_t i = 0; i < _sides.Count(); i++) {
|
||||
|
|
Loading…
Reference in New Issue