Browse Source

fix(chase): align hud seed copy and refresh assertions

Made-with: Cursor
master
npmrun 2 weeks ago
parent
commit
fcc7784744
  1. 2
      src/stages/page_chase.ts
  2. 56
      tests/stages/page_chase.test.ts

2
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();

56
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", () => {

Loading…
Cancel
Save