|
|
|
@ -173,6 +173,23 @@ describe("chase game model", () => { |
|
|
|
expect(mockedGenerateChaseRound).toHaveBeenCalledTimes(1); |
|
|
|
}); |
|
|
|
|
|
|
|
it("retryRound keeps exactly same graph and start positions", () => { |
|
|
|
mockedGenerateChaseRound.mockReturnValueOnce(makeRound(88, "normal")); |
|
|
|
const model = ChaseGameModel.createWithSeed({ seed: 88, difficulty: "normal" }); |
|
|
|
const initial = model.getState().snapshot; |
|
|
|
|
|
|
|
model.moveThief("A"); |
|
|
|
model.retryRound(); |
|
|
|
const retried = model.getState().snapshot; |
|
|
|
|
|
|
|
expect(retried.graph).toEqual(initial.graph); |
|
|
|
expect(retried.thiefStartNodeId).toBe(initial.thiefStartNodeId); |
|
|
|
expect(retried.guardStartNodeId).toBe(initial.guardStartNodeId); |
|
|
|
expect(retried.exitNodeId).toBe(initial.exitNodeId); |
|
|
|
expect(retried.thiefNodeId).toBe(initial.thiefNodeId); |
|
|
|
expect(retried.guardNodeId).toBe(initial.guardNodeId); |
|
|
|
}); |
|
|
|
|
|
|
|
it("newRound switches seed/difficulty and keeps winCount", () => { |
|
|
|
mockedGenerateChaseRound |
|
|
|
.mockReturnValueOnce(makeRound(55, "easy")) |
|
|
|
@ -204,6 +221,29 @@ describe("chase game model", () => { |
|
|
|
expect(state.snapshot.difficulty).toBe("easy"); |
|
|
|
}); |
|
|
|
|
|
|
|
it("newRound with new seed produces a new round snapshot", () => { |
|
|
|
const base = makeRound(300, "normal"); |
|
|
|
const next = makeRound(301, "normal"); |
|
|
|
next.snapshot.graph.nodes.E = { id: "E", q: 4, r: 0, neighbors: [] }; |
|
|
|
next.snapshot.thiefStartNodeId = "A"; |
|
|
|
next.snapshot.guardStartNodeId = "C"; |
|
|
|
next.snapshot.exitNodeId = "D"; |
|
|
|
next.snapshot.thiefNodeId = "A"; |
|
|
|
next.snapshot.guardNodeId = "C"; |
|
|
|
|
|
|
|
mockedGenerateChaseRound.mockReturnValueOnce(base).mockReturnValueOnce(next); |
|
|
|
const model = ChaseGameModel.createWithSeed({ seed: 300, difficulty: "normal" }); |
|
|
|
const before = model.getState().snapshot; |
|
|
|
|
|
|
|
model.newRound(301, "normal"); |
|
|
|
const after = model.getState().snapshot; |
|
|
|
|
|
|
|
expect(after.seed).toBe(301); |
|
|
|
expect(after).not.toEqual(before); |
|
|
|
expect(Object.keys(after.graph.nodes)).toContain("E"); |
|
|
|
expect(after.thiefStartNodeId).toBe("A"); |
|
|
|
}); |
|
|
|
|
|
|
|
it("retryRound resets rng so same move sequence is reproducible", () => { |
|
|
|
const easyRound = { |
|
|
|
snapshot: { |
|
|
|
|