Add gm harness with batch chance tools for play.

Main world layer can loop on the chance tool (requests array) until settlement JSON. Driver forwards output deltas; standalone chance worker accepts batch requests. play_slots.chance gates the harness.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-25 00:49:19 +08:00
co-authored by Cursor
parent 6b4156fd0f
commit 8360e885bb
9 changed files with 428 additions and 32 deletions
+11 -9
View File
@@ -27,6 +27,7 @@ import {
} from "../src/blackboard/table-cells.js";
import {
executeChance,
executeChanceBatch,
parseChanceRequest,
} from "../src/skills/chance-tools.js";
import { synthesizeContextOrderFromWorkers } from "../src/skills/context-order.js";
@@ -185,15 +186,16 @@ describe("chance tools", () => {
expect(result.detail.win).toBe(true);
});
it("draws from pool", () => {
const result = executeChance({
op: "draw",
pool: ["甲", "乙", "丙"],
count: 2,
unique: true,
});
expect(result.ok).toBe(true);
expect((result.detail.drawn as string[]).length).toBe(2);
it("batch executes multiple requests with ids", () => {
const batch = executeChanceBatch([
{ id: "a", op: "roll", expression: "1d6" },
{ id: "b", op: "compare", left: 10, right: 5, mode: "gte" },
]);
expect(batch.schema).toBe("chance.batch.v1");
expect(batch.ok).toBe(true);
expect(batch.results).toHaveLength(2);
expect(batch.results[0]!.id).toBe("a");
expect(batch.results[1]!.id).toBe("b");
});
});