Optional chaining for cases like stealth rock

This commit is contained in:
Christopher Schmidt 2025-01-25 13:01:10 -05:00
parent b0d29eb232
commit 3027cd8630
1 changed files with 1 additions and 1 deletions

View File

@ -3062,7 +3062,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
damageAndUpdate(damage: number, result?: DamageResult, critical: boolean = false, ignoreSegments: boolean = false, preventEndure: boolean = false, ignoreFaintPhase: boolean = false, source?: Pokemon): number {
// When damage is done from any source (Move or Indirect damage, e.g. weather), store latest occurrence in damageSources[0]
if (result !== undefined) {
this.turnData.damageSources.unshift(result);
this.turnData?.damageSources?.unshift(result);
}
const damagePhase = new DamageAnimPhase(this.getBattlerIndex(), damage, result as DamageResult, critical);
globalScene.unshiftPhase(damagePhase);