diff --git a/src/stages/page_chase.ts b/src/stages/page_chase.ts index c91db6f..88c4baf 100644 --- a/src/stages/page_chase.ts +++ b/src/stages/page_chase.ts @@ -45,6 +45,9 @@ export default class ChaseScene extends BaseScene { private retryButton = new Graphics(); private newGameButton = new Graphics(); private restartButton = new Graphics(); + private retryLabel = new Text({ text: "" }); + private newGameLabel = new Text({ text: "" }); + private restartLabel = new Text({ text: "" }); private seedInputElement?: HTMLInputElement; private readonly documentRef?: DocumentLike; private selectedDifficulty: Difficulty = "normal"; @@ -336,7 +339,8 @@ export default class ChaseScene extends BaseScene { this.retryButton.roundRect(0, 0, 86, 34, 8); this.retryButton.fill({ color: 0x2563eb, alpha: 0.95 }); this.resultOverlay.addChild(this.retryButton); - this.resultOverlay.addChild(this.createOverlayLabel("重试", 43, 59)); + this.retryLabel = this.createOverlayLabel("重试", 43, 59); + this.resultOverlay.addChild(this.retryLabel); this.newGameButton.eventMode = "static"; this.newGameButton.cursor = "pointer"; @@ -346,7 +350,8 @@ export default class ChaseScene extends BaseScene { this.newGameButton.roundRect(0, 0, 96, 34, 8); this.newGameButton.fill({ color: 0x0ea5e9, alpha: 0.95 }); this.resultOverlay.addChild(this.newGameButton); - this.resultOverlay.addChild(this.createOverlayLabel("新一局", 146, 59)); + this.newGameLabel = this.createOverlayLabel("新一局", 146, 59); + this.resultOverlay.addChild(this.newGameLabel); this.restartButton.eventMode = "static"; this.restartButton.cursor = "pointer"; @@ -356,7 +361,8 @@ export default class ChaseScene extends BaseScene { this.restartButton.roundRect(0, 0, 108, 34, 8); this.restartButton.fill({ color: 0x22c55e, alpha: 0.95 }); this.resultOverlay.addChild(this.restartButton); - this.resultOverlay.addChild(this.createOverlayLabel("重新开始", 54, 59)); + this.restartLabel = this.createOverlayLabel("重新开始", 54, 59); + this.resultOverlay.addChild(this.restartLabel); } private createOverlayLabel(text: string, x: number, y: number): Text { @@ -461,15 +467,21 @@ export default class ChaseScene extends BaseScene { if (status === "win") { this.resultText.text = "成功逃脱!"; this.restartButton.visible = true; + this.restartLabel.visible = true; this.retryButton.visible = false; + this.retryLabel.visible = false; this.newGameButton.visible = false; + this.newGameLabel.visible = false; return; } this.resultText.text = loseReason === "trapped" ? "你已无路可走" : "你被抓住了"; this.restartButton.visible = false; + this.restartLabel.visible = false; this.retryButton.visible = true; + this.retryLabel.visible = true; this.newGameButton.visible = true; + this.newGameLabel.visible = true; } private canRunEndAction(): boolean { diff --git a/tests/stages/page_chase.test.ts b/tests/stages/page_chase.test.ts index f1b01e8..d14c3bf 100644 --- a/tests/stages/page_chase.test.ts +++ b/tests/stages/page_chase.test.ts @@ -299,6 +299,12 @@ describe("chase stage skeleton", () => { expect((scene as any).resultOverlay.visible).toBe(true); expect((scene as any).resultText.text).toContain("成功逃脱"); + expect((scene as any).restartButton.visible).toBe(true); + expect((scene as any).restartLabel.visible).toBe(true); + expect((scene as any).retryButton.visible).toBe(false); + expect((scene as any).retryLabel.visible).toBe(false); + expect((scene as any).newGameButton.visible).toBe(false); + expect((scene as any).newGameLabel.visible).toBe(false); (scene as any).restartButton.emit("pointerdown"); (scene as any).restartButton.emit("pointerdown"); @@ -327,6 +333,12 @@ describe("chase stage skeleton", () => { }); void (retryScene as any).onSceneLayout(); expect((retryScene as any).resultText.text).toContain("你已无路可走"); + expect((retryScene as any).retryButton.visible).toBe(true); + expect((retryScene as any).retryLabel.visible).toBe(true); + expect((retryScene as any).newGameButton.visible).toBe(true); + expect((retryScene as any).newGameLabel.visible).toBe(true); + expect((retryScene as any).restartButton.visible).toBe(false); + expect((retryScene as any).restartLabel.visible).toBe(false); (retryScene as any).retryButton.emit("pointerdown"); (retryScene as any).retryButton.emit("pointerdown"); expect(retryRound).toHaveBeenCalledTimes(1);