Use early return in Pokemon#isOffsetBySubstitute

This commit is contained in:
NightKev 2025-06-06 16:55:56 -07:00
parent 19575820cc
commit 1318dd5225

View File

@ -1292,17 +1292,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
*/ */
isOffsetBySubstitute(): boolean { isOffsetBySubstitute(): boolean {
const substitute = this.getTag(SubstituteTag); const substitute = this.getTag(SubstituteTag);
if (substitute) { if (!substitute || substitute.sprite === undefined) {
if (substitute.sprite === undefined) {
return false; return false;
} }
// During the Pokemon's MoveEffect phase, the offset is removed to put the Pokemon "in focus" // During the Pokemon's MoveEffect phase, the offset is removed to put the Pokemon "in focus"
const currentPhase = globalScene.getCurrentPhase(); const currentPhase = globalScene.getCurrentPhase();
return !(currentPhase?.is("MoveEffectPhase") && currentPhase.getPokemon() === this); return !(currentPhase?.is("MoveEffectPhase") && currentPhase.getPokemon() === this);
} }
return false;
}
/** If this Pokemon has a Substitute on the field, removes its sprite from the field. */ /** If this Pokemon has a Substitute on the field, removes its sprite from the field. */
destroySubstitute(): void { destroySubstitute(): void {