From 30cc6aba8947aa6de2f2629e93f8d5365a13f940 Mon Sep 17 00:00:00 2001 From: flx-sta <50131232+flx-sta@users.noreply.github.com> Date: Fri, 9 Aug 2024 06:33:31 -0700 Subject: [PATCH] [Bug] Fix DNA splicers broken from the strictnull check (#3454) This makes DNA-splicer work again --- src/data/status-effect.ts | 6 +++--- src/field/pokemon.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/status-effect.ts b/src/data/status-effect.ts index 828c52cae13..4381db5c2c6 100644 --- a/src/data/status-effect.ts +++ b/src/data/status-effect.ts @@ -115,11 +115,11 @@ export function getRandomStatusEffect(statusEffectA: StatusEffect, statusEffectB * @param statusA The first Status * @param statusB The second Status */ -export function getRandomStatus(statusA: Status, statusB: Status): Status { - if (statusA === undefined || statusA.effect === StatusEffect.NONE || statusA.effect === StatusEffect.FAINT) { +export function getRandomStatus(statusA: Status | null, statusB: Status | null): Status | null { + if (!statusA || statusA.effect === StatusEffect.NONE || statusA.effect === StatusEffect.FAINT) { return statusB; } - if (statusB === undefined || statusB.effect === StatusEffect.NONE || statusB.effect === StatusEffect.FAINT) { + if (!statusB || statusB.effect === StatusEffect.NONE || statusB.effect === StatusEffect.FAINT) { return statusA; } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index bf9cc6db42a..b4461c21354 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3614,7 +3614,7 @@ export class PlayerPokemon extends Pokemon { if (!this.isFainted()) { // If this Pokemon hasn't fainted, make sure the HP wasn't set over the new maximum this.hp = Math.min(this.hp, this.stats[Stat.HP]); - this.status = getRandomStatus(this.status!, pokemon.status!); // Get a random valid status between the two // TODO: are the bangs correct? + this.status = getRandomStatus(this.status, pokemon.status); // Get a random valid status between the two } else if (!pokemon.isFainted()) { // If this Pokemon fainted but the other hasn't, make sure the HP wasn't set to zero this.hp = Math.max(this.hp, 1);