From fcc7784744d40b1525e359d44cbb4533beeae4e9 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Mon, 27 Apr 2026 00:18:16 +0800 Subject: [PATCH] fix(chase): align hud seed copy and refresh assertions Made-with: Cursor --- src/stages/page_chase.ts | 2 +- tests/stages/page_chase.test.ts | 56 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/stages/page_chase.ts b/src/stages/page_chase.ts index d1088e4..ff7a2a9 100644 --- a/src/stages/page_chase.ts +++ b/src/stages/page_chase.ts @@ -168,7 +168,7 @@ export default class ChaseScene extends BaseScene { const state = this.model.getState(); this.winCountText.text = `成功次数: ${state.winCount}`; - this.seedText.text = `Seed: ${state.snapshot.seed}`; + this.seedText.text = `当前 seed:${state.snapshot.seed}`; this.hudText.text = `Turn ${state.turn} | ${state.snapshot.status} | thief=${state.snapshot.thiefNodeId} guard=${state.snapshot.guardNodeId}`; this.setupText.text = `difficulty=${this.selectedDifficulty} | seed=${this.seedInput.trim() || "(auto)"} | locked=${this.difficultyLocked ? "yes" : "no"}`; this.drawDifficultyButtons(); diff --git a/tests/stages/page_chase.test.ts b/tests/stages/page_chase.test.ts index 6d4f87b..1e8e577 100644 --- a/tests/stages/page_chase.test.ts +++ b/tests/stages/page_chase.test.ts @@ -395,7 +395,7 @@ describe("chase stage skeleton", () => { }); void (scene as any).onSceneLayout(); expect((scene as any).winCountText.text).toContain("成功次数: 0"); - expect((scene as any).seedText.text).toContain("Seed: 123"); + expect((scene as any).seedText.text).toContain("当前 seed:123"); }); it("refreshes hud after state change", () => { @@ -423,7 +423,59 @@ describe("chase stage skeleton", () => { void (scene as any).onSceneLayout(); scene.refreshView(); expect((scene as any).winCountText.text).toContain("成功次数: 2"); - expect((scene as any).seedText.text).toContain("Seed: 999"); + expect((scene as any).seedText.text).toContain("当前 seed:999"); + }); + + it("refreshes success counter on win state change", () => { + const getState = vi + .fn() + .mockReturnValueOnce({ + ...createSceneState(), + winCount: 0, + }) + .mockReturnValueOnce({ + ...createSceneState(), + winCount: 1, + snapshot: { + ...createSceneState().snapshot, + status: "win", + }, + }); + const scene = new ChaseScene({ + model: { + getState, + moveThief: vi.fn(), + newRound: vi.fn(), + retryRound: vi.fn(), + } as any, + }); + void (scene as any).onSceneLayout(); + scene.refreshView(); + expect((scene as any).winCountText.text).toContain("成功次数: 1"); + }); + + it("refreshes seed text after starting a new round", () => { + const getState = vi + .fn() + .mockReturnValueOnce(createSceneState()) + .mockReturnValue({ + ...createSceneState(), + snapshot: { + ...createSceneState().snapshot, + seed: 2027, + }, + }); + const scene = new ChaseScene({ + model: { + getState, + moveThief: vi.fn(), + newRound: vi.fn(), + retryRound: vi.fn(), + } as any, + }); + void (scene as any).onSceneLayout(); + scene.refreshView(); + expect((scene as any).seedText.text).toContain("当前 seed:2027"); }); it("renders move highlights matching available moves count", () => {