|
|
|
@ -16,14 +16,21 @@ describe("chase round generator", () => { |
|
|
|
const round = generateChaseRound({ seed: 424242, difficulty: "easy" }); |
|
|
|
|
|
|
|
expect({ |
|
|
|
startNodeId: round.startNodeId, |
|
|
|
exitNodeId: round.exitNodeId, |
|
|
|
seed: round.snapshot.seed, |
|
|
|
difficulty: round.snapshot.difficulty, |
|
|
|
thiefStartNodeId: round.snapshot.thiefStartNodeId, |
|
|
|
guardStartNodeId: round.snapshot.guardStartNodeId, |
|
|
|
thiefNodeId: round.snapshot.thiefNodeId, |
|
|
|
guardNodeId: round.snapshot.guardNodeId, |
|
|
|
exitNodeId: round.snapshot.exitNodeId, |
|
|
|
status: round.snapshot.status, |
|
|
|
hasEscapePath: round.meta.hasEscapePath, |
|
|
|
nodeCount: Object.keys(round.graph.nodes).length, |
|
|
|
edgeCount: round.graph.edgeList.length, |
|
|
|
firstFiveNodeIds: Object.keys(round.graph.nodes).slice(0, 5), |
|
|
|
nodeCount: Object.keys(round.snapshot.graph.nodes).length, |
|
|
|
edgeCount: round.snapshot.graph.edgeList.length, |
|
|
|
firstFiveNodeIds: Object.keys(round.snapshot.graph.nodes).slice(0, 5), |
|
|
|
}).toMatchInlineSnapshot(` |
|
|
|
{ |
|
|
|
"difficulty": "easy", |
|
|
|
"edgeCount": 19, |
|
|
|
"exitNodeId": "0,-1", |
|
|
|
"firstFiveNodeIds": [ |
|
|
|
@ -33,16 +40,21 @@ describe("chase round generator", () => { |
|
|
|
"2,-1", |
|
|
|
"1,-2", |
|
|
|
], |
|
|
|
"guardNodeId": "4,-5", |
|
|
|
"guardStartNodeId": "4,-5", |
|
|
|
"hasEscapePath": true, |
|
|
|
"nodeCount": 20, |
|
|
|
"startNodeId": "4,-5", |
|
|
|
"seed": 424242, |
|
|
|
"status": "playing", |
|
|
|
"thiefNodeId": "4,-5", |
|
|
|
"thiefStartNodeId": "4,-5", |
|
|
|
} |
|
|
|
`);
|
|
|
|
}); |
|
|
|
|
|
|
|
it("generates graph node count between 20 and 30", () => { |
|
|
|
const round = generateChaseRound({ seed: 11, difficulty: "normal" }); |
|
|
|
const nodeCount = Object.keys(round.graph.nodes).length; |
|
|
|
const nodeCount = Object.keys(round.snapshot.graph.nodes).length; |
|
|
|
expect(nodeCount).toBeGreaterThanOrEqual(20); |
|
|
|
expect(nodeCount).toBeLessThanOrEqual(30); |
|
|
|
}); |
|
|
|
@ -50,9 +62,9 @@ describe("chase round generator", () => { |
|
|
|
it("ensures an escape path exists", () => { |
|
|
|
const round = generateChaseRound({ seed: 99, difficulty: "hard" }); |
|
|
|
const pathLength = shortestPathLength( |
|
|
|
round.graph, |
|
|
|
round.startNodeId, |
|
|
|
round.exitNodeId, |
|
|
|
round.snapshot.graph, |
|
|
|
round.snapshot.thiefNodeId, |
|
|
|
round.snapshot.exitNodeId, |
|
|
|
); |
|
|
|
|
|
|
|
expect(round.meta.hasEscapePath).toBe(true); |
|
|
|
|