From 6b5bc5b83020b63d9871506f7167c12bcc1eafff Mon Sep 17 00:00:00 2001 From: Matthew Date: Fri, 5 Apr 2024 17:50:01 -0400 Subject: [PATCH] Fix duplicate transition at the end of batch hatching --- src/egg-hatch-phase.ts | 5 +++-- src/phases.ts | 20 +++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/egg-hatch-phase.ts b/src/egg-hatch-phase.ts index 469bddb4d..39b98b66a 100644 --- a/src/egg-hatch-phase.ts +++ b/src/egg-hatch-phase.ts @@ -154,8 +154,9 @@ export class EggHatchPhase extends Phase { }); } end() { - this.eggHatchHandler.clear() - super.end() + if (this.scene.findPhase((p) => p instanceof EggHatchPhase)) + this.eggHatchHandler.clear(); + super.end(); } doEggShake(intensity: number, repeatCount?: integer, count?: integer): Promise { diff --git a/src/phases.ts b/src/phases.ts index 78f6cbd5c..cb955642a 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -4090,19 +4090,17 @@ export class EggLapsePhase extends Phase { start() { super.start(); - const eggsToHatch: Egg[] = []; + const eggsToHatch: Egg[] = this.scene.gameData.eggs.filter((egg: Egg) => { + return --egg.hatchWaves < 1 + }) - for (let egg of this.scene.gameData.eggs) { - if (--egg.hatchWaves < 1) - eggsToHatch.push(egg); - } - - if (eggsToHatch.length) + if (eggsToHatch.length) { this.scene.queueMessage('Oh?'); - - for (let egg of eggsToHatch) - this.scene.unshiftPhase(new EggHatchPhase(this.scene, egg)); - + + for (let egg of eggsToHatch) + this.scene.unshiftPhase(new EggHatchPhase(this.scene, egg)); + + } this.end(); } }