@kradle/challenges-sdk 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -1
- package/LLM_README.md +286 -193
- package/MIGRATION-0.13.md +109 -0
- package/README.md +98 -90
- package/dist/engine.d.ts +8 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +17 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -16
- package/dist/index.js.map +1 -1
- package/dist/runtime/builder.d.ts +33 -0
- package/dist/runtime/builder.d.ts.map +1 -0
- package/dist/runtime/builder.js +357 -0
- package/dist/runtime/builder.js.map +1 -0
- package/dist/runtime/errors.d.ts +61 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +71 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/reducer.d.ts +205 -0
- package/dist/runtime/reducer.d.ts.map +1 -0
- package/dist/runtime/reducer.js +2025 -0
- package/dist/runtime/reducer.js.map +1 -0
- package/dist/runtime/rules.d.ts +29 -0
- package/dist/runtime/rules.d.ts.map +1 -0
- package/dist/runtime/rules.js +23 -0
- package/dist/runtime/rules.js.map +1 -0
- package/dist/runtime/sandbox.d.ts +2 -1
- package/dist/runtime/sandbox.d.ts.map +1 -1
- package/dist/runtime/sandbox.js +7 -4
- package/dist/runtime/sandbox.js.map +1 -1
- package/dist/runtime/time.d.ts +33 -0
- package/dist/runtime/time.d.ts.map +1 -0
- package/dist/runtime/time.js +53 -0
- package/dist/runtime/time.js.map +1 -0
- package/dist/runtime/types.d.ts +963 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +25 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/wire.d.ts +858 -0
- package/dist/runtime/wire.d.ts.map +1 -0
- package/dist/runtime/wire.js +28 -0
- package/dist/runtime/wire.js.map +1 -0
- package/dist/runtime/world.d.ts +58 -3
- package/dist/runtime/world.d.ts.map +1 -1
- package/dist/runtime/world.js +12 -0
- package/dist/runtime/world.js.map +1 -1
- package/dist/structures.d.ts +119 -0
- package/dist/structures.d.ts.map +1 -0
- package/dist/structures.js +279 -0
- package/dist/structures.js.map +1 -0
- package/dist/test/harness.d.ts +280 -0
- package/dist/test/harness.d.ts.map +1 -0
- package/dist/{runtime → test}/harness.js +193 -68
- package/dist/test/harness.js.map +1 -0
- package/dist/test/helpers.d.ts +8 -0
- package/dist/test/helpers.d.ts.map +1 -0
- package/dist/test/helpers.js +12 -0
- package/dist/test/helpers.js.map +1 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/{runtime → test}/index.js +3 -1
- package/dist/test/index.js.map +1 -0
- package/package.json +31 -16
- package/dist/runtime/examples/capture-the-flag.d.ts +0 -33
- package/dist/runtime/examples/capture-the-flag.d.ts.map +0 -1
- package/dist/runtime/examples/capture-the-flag.js +0 -79
- package/dist/runtime/examples/capture-the-flag.js.map +0 -1
- package/dist/runtime/examples/climb.d.ts +0 -34
- package/dist/runtime/examples/climb.d.ts.map +0 -1
- package/dist/runtime/examples/climb.js +0 -54
- package/dist/runtime/examples/climb.js.map +0 -1
- package/dist/runtime/examples/four-bridges.d.ts +0 -107
- package/dist/runtime/examples/four-bridges.d.ts.map +0 -1
- package/dist/runtime/examples/four-bridges.js +0 -294
- package/dist/runtime/examples/four-bridges.js.map +0 -1
- package/dist/runtime/examples/herding.d.ts +0 -59
- package/dist/runtime/examples/herding.d.ts.map +0 -1
- package/dist/runtime/examples/herding.js +0 -181
- package/dist/runtime/examples/herding.js.map +0 -1
- package/dist/runtime/examples/skywars.d.ts +0 -116
- package/dist/runtime/examples/skywars.d.ts.map +0 -1
- package/dist/runtime/examples/skywars.js +0 -253
- package/dist/runtime/examples/skywars.js.map +0 -1
- package/dist/runtime/harness.d.ts +0 -176
- package/dist/runtime/harness.d.ts.map +0 -1
- package/dist/runtime/harness.js.map +0 -1
- package/dist/runtime/index.d.ts +0 -2
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/sdk.d.ts +0 -1038
- package/dist/runtime/sdk.d.ts.map +0 -1
- package/dist/runtime/sdk.js +0 -1271
- package/dist/runtime/sdk.js.map +0 -1
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Fake = exports.Game = exports.canonical = void 0;
|
|
3
|
+
exports.Fake = exports.Game = exports.defaultPosition = exports.canonical = void 0;
|
|
4
4
|
exports.sandboxed = sandboxed;
|
|
5
5
|
// A stand-in arena for tests. It feeds events, collects actions, keeps the event
|
|
6
6
|
// log, and checks on every reduction that the reducer is pure, deterministic, and
|
|
7
7
|
// that the state survives a JSON round trip. No test framework dependency: it
|
|
8
8
|
// throws plain errors, so it runs under node:test, vitest, bun test or jest.
|
|
9
9
|
const node_fs_1 = require("node:fs");
|
|
10
|
-
const sandbox_registry_js_1 = require("
|
|
11
|
-
const
|
|
10
|
+
const sandbox_registry_js_1 = require("../runtime/sandbox-registry.js");
|
|
11
|
+
const time_js_1 = require("../runtime/time.js");
|
|
12
|
+
const wire_js_1 = require("../runtime/wire.js");
|
|
13
|
+
const world_js_1 = require("../runtime/world.js");
|
|
14
|
+
/** `isActive` is a non-enumerable getter the reducer re-attaches after a JSON round trip; the harness does the same. */
|
|
15
|
+
function attachDerived(state) {
|
|
16
|
+
for (const p of Object.values(state.players)) {
|
|
17
|
+
Object.defineProperty(p, "isActive", {
|
|
18
|
+
get() {
|
|
19
|
+
return !this.eliminated;
|
|
20
|
+
},
|
|
21
|
+
enumerable: false,
|
|
22
|
+
configurable: true,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return state;
|
|
26
|
+
}
|
|
12
27
|
/** JSON with sorted keys, so key order never counts as a difference. */
|
|
13
28
|
const canonical = (v) => JSON.stringify(v, (_k, x) => x && typeof x === "object" && !Array.isArray(x) ? Object.fromEntries(Object.entries(x).sort()) : x);
|
|
14
29
|
exports.canonical = canonical;
|
|
@@ -49,7 +64,7 @@ async function sandboxed(challenge) {
|
|
|
49
64
|
if (!bundle)
|
|
50
65
|
return challenge;
|
|
51
66
|
// Lazy: `ses` and the lockdown only enter a process that asked for them.
|
|
52
|
-
const { loadBundleFile } = require("
|
|
67
|
+
const { loadBundleFile } = require("../runtime/sandbox.js");
|
|
53
68
|
const loaded = await loadBundleFile(bundle);
|
|
54
69
|
const want = challenge.manifest?.name;
|
|
55
70
|
const got = loaded.manifest?.name;
|
|
@@ -58,14 +73,22 @@ async function sandboxed(challenge) {
|
|
|
58
73
|
}
|
|
59
74
|
return loaded;
|
|
60
75
|
}
|
|
76
|
+
/** Where `begin` puts a participant without an `at`: a row along x, two blocks apart. */
|
|
77
|
+
const defaultPosition = (index) => ({ x: index * 2, y: -60, z: 0 });
|
|
78
|
+
exports.defaultPosition = defaultPosition;
|
|
79
|
+
/** A fake engine around one challenge: feeds events, keeps the state, records the actions. */
|
|
61
80
|
class Game {
|
|
62
81
|
challenge;
|
|
63
|
-
state
|
|
82
|
+
/** The whole reducer state: the SDK's fields, the players, the votes, the mirror. */
|
|
83
|
+
reducerState;
|
|
84
|
+
/** Every event dispatched so far. */
|
|
64
85
|
log = [];
|
|
86
|
+
/** Every action returned so far. */
|
|
65
87
|
actions = [];
|
|
88
|
+
/** The actions of the last dispatch. */
|
|
66
89
|
last = [];
|
|
67
|
-
/** The harness's tick step, a test setting
|
|
68
|
-
step =
|
|
90
|
+
/** The harness's tick step, a test setting. The arena sends every server tick, so the default is 1. */
|
|
91
|
+
step = 1;
|
|
69
92
|
attempts = 0;
|
|
70
93
|
/** The state this game started from: `init()`, or the checkpoint of `resume`. `replay` starts here. */
|
|
71
94
|
origin;
|
|
@@ -74,14 +97,37 @@ class Game {
|
|
|
74
97
|
constructor(challenge, state) {
|
|
75
98
|
this.challenge = challenge;
|
|
76
99
|
requireBundleUnderTheCommand(challenge);
|
|
77
|
-
this.
|
|
78
|
-
this.origin = JSON.stringify(this.
|
|
100
|
+
this.reducerState = attachDerived(state ?? challenge.init());
|
|
101
|
+
this.origin = JSON.stringify(this.reducerState);
|
|
102
|
+
}
|
|
103
|
+
/** The shared challenge data (`g.state` in a rule). */
|
|
104
|
+
get state() {
|
|
105
|
+
return this.reducerState.game;
|
|
106
|
+
}
|
|
107
|
+
/** The current phase; `null` before the first entry and without phases. */
|
|
108
|
+
get phase() {
|
|
109
|
+
return this.reducerState.phase;
|
|
110
|
+
}
|
|
111
|
+
/** The run's stage. */
|
|
112
|
+
get status() {
|
|
113
|
+
return this.reducerState.status;
|
|
79
114
|
}
|
|
115
|
+
/** One participant's reducer record: observations, `state`, `score`. */
|
|
116
|
+
participant(name) {
|
|
117
|
+
const p = this.reducerState.players[name];
|
|
118
|
+
if (!p)
|
|
119
|
+
throw new Error(`"${name}" is not a participant (roster: ${Object.keys(this.reducerState.players).join(", ")})`);
|
|
120
|
+
return p;
|
|
121
|
+
}
|
|
122
|
+
/** One reduction. Asserts that `reduce` did not mutate its input. */
|
|
80
123
|
dispatch(event) {
|
|
81
|
-
const before = JSON.stringify(this.
|
|
82
|
-
const a = this.challenge.reduce(this.
|
|
83
|
-
assertEqual(JSON.stringify(this.
|
|
84
|
-
|
|
124
|
+
const before = JSON.stringify(this.reducerState);
|
|
125
|
+
const a = this.challenge.reduce(this.reducerState, event);
|
|
126
|
+
assertEqual(JSON.stringify(this.reducerState), before, "reduce() mutated its input state");
|
|
127
|
+
// The arena posts the actions to its main thread: a value the structured clone refuses (a Proxy
|
|
128
|
+
// view, a function) would kill the run there, so the harness refuses it here.
|
|
129
|
+
structuredClone(a.actions);
|
|
130
|
+
this.reducerState = attachDerived(JSON.parse(JSON.stringify(a.state))); // a checkpoint is a JSON string
|
|
85
131
|
this.log.push(event);
|
|
86
132
|
this.last = a.actions;
|
|
87
133
|
this.actions.push(...a.actions);
|
|
@@ -89,29 +135,30 @@ class Game {
|
|
|
89
135
|
}
|
|
90
136
|
/** Ticks in steps of `step`, and lands exactly on `serverTick` (the last step is shorter when needed). */
|
|
91
137
|
tickTo(serverTick) {
|
|
92
|
-
for (let t = this.
|
|
138
|
+
for (let t = this.reducerState.tick + this.step; t <= serverTick; t += this.step)
|
|
93
139
|
this.dispatch({ type: "tick", serverTick: t });
|
|
94
|
-
if (this.
|
|
140
|
+
if (this.reducerState.tick < serverTick)
|
|
95
141
|
this.dispatch({ type: "tick", serverTick });
|
|
96
142
|
}
|
|
143
|
+
/** Advances `n` engine steps of `step` ticks each. */
|
|
97
144
|
tick(n = 1) {
|
|
98
|
-
this.tickTo(this.
|
|
145
|
+
this.tickTo(this.reducerState.tick + n * this.step);
|
|
99
146
|
}
|
|
100
147
|
/** Advance by a duration: "35s", "2m", or ticks. */
|
|
101
148
|
after(d) {
|
|
102
|
-
this.tickTo(this.
|
|
149
|
+
this.tickTo(this.reducerState.tick + (0, time_js_1.toTicks)(d));
|
|
103
150
|
}
|
|
104
151
|
/** Advance until `d` after game start. */
|
|
105
152
|
at(d) {
|
|
106
|
-
this.tickTo(this.
|
|
153
|
+
this.tickTo(this.reducerState.startTick + (0, time_js_1.toTicks)(d));
|
|
107
154
|
}
|
|
108
155
|
/**
|
|
109
|
-
* run_started, every join, the first tick, and the setup
|
|
110
|
-
* challenge has a setup. A roster entry is a role (`{ alice: "climber" }`),
|
|
111
|
-
* role with the player's position and sample fields (`{ alice: { role: "climber",
|
|
112
|
-
* at: { x: 0, y: -60, z: 0 } } }`)
|
|
113
|
-
* `start`
|
|
114
|
-
* the
|
|
156
|
+
* run_started, every join, the first tick with every participant's position, and the setup
|
|
157
|
+
* confirmations when the challenge has a setup. A roster entry is a role (`{ alice: "climber" }`),
|
|
158
|
+
* or the role with the player's position and sample fields (`{ alice: { role: "climber",
|
|
159
|
+
* at: { x: 0, y: -60, z: 0 } } }`). Without `at` a participant gets `defaultPosition(i)`, so the
|
|
160
|
+
* initializers and `start` see a position, as they do in the arena. `positions: false` sends no
|
|
161
|
+
* sample: the run stays in CONNECTING until a test moves every player.
|
|
115
162
|
*/
|
|
116
163
|
begin(seed, participants, opts = {}) {
|
|
117
164
|
const entries = Object.entries(participants).map(([name, entry]) => [name, typeof entry === "string" ? { role: entry } : entry]);
|
|
@@ -120,40 +167,60 @@ class Game {
|
|
|
120
167
|
seed,
|
|
121
168
|
participants: entries.map(([name, e]) => ({ name, role: e.role })),
|
|
122
169
|
params: opts.params ?? {},
|
|
123
|
-
capabilities: opts.capabilities ??
|
|
170
|
+
capabilities: opts.capabilities ?? wire_js_1.ALL_CAPABILITIES,
|
|
124
171
|
locations: opts.locations,
|
|
125
172
|
markers: opts.markers,
|
|
126
173
|
});
|
|
127
174
|
for (const [name] of entries)
|
|
128
175
|
this.dispatch({ type: "player_joined", name });
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
176
|
+
if (opts.positions === false)
|
|
177
|
+
return this;
|
|
178
|
+
const samples = entries.map(([name, { role: _role, at, ...rest }], i) => ({
|
|
179
|
+
name,
|
|
180
|
+
participant: true,
|
|
181
|
+
pos: at ?? (0, exports.defaultPosition)(i),
|
|
182
|
+
...rest,
|
|
183
|
+
}));
|
|
184
|
+
this.dispatch({ type: "tick", serverTick: this.reducerState.tick + this.step, players: samples });
|
|
185
|
+
this.confirmSetup(opts.setupOk ?? true);
|
|
186
|
+
return this;
|
|
187
|
+
}
|
|
188
|
+
/** Answers every pending setup batch in order (each confirmation may send the next one), from the reducer state. */
|
|
189
|
+
confirmSetup(ok = true) {
|
|
190
|
+
for (let guard = 0; guard < 1000; guard++) {
|
|
191
|
+
const setup = this.reducerState.setup;
|
|
192
|
+
if (this.reducerState.status !== "SETUP" || !setup)
|
|
193
|
+
return;
|
|
139
194
|
this.dispatch({
|
|
140
195
|
type: "effect_result",
|
|
141
|
-
id:
|
|
196
|
+
id: `setup:${setup.confirmed}`,
|
|
142
197
|
ok,
|
|
143
198
|
detail: ok ? undefined : "fill #3 failed: unknown block",
|
|
199
|
+
failed: ok ? undefined : [{ index: 3, detail: "unknown block" }],
|
|
144
200
|
});
|
|
201
|
+
if (!ok)
|
|
202
|
+
return;
|
|
145
203
|
}
|
|
146
|
-
|
|
204
|
+
throw new Error("confirmSetup: 1000 confirmations and the run is still in SETUP");
|
|
205
|
+
}
|
|
206
|
+
/** Answers a named batch (`g.batch(name, ...)`): the engine ran it, with the failed effects listed. */
|
|
207
|
+
batchResult(name, ok, failed = []) {
|
|
208
|
+
const id = Object.entries(this.reducerState.batches).find(([, n]) => n === name)?.[0];
|
|
209
|
+
if (!id)
|
|
210
|
+
throw new Error(`no pending batch named "${name}"`);
|
|
211
|
+
this.dispatch({ type: "effect_result", id, ok, failed, detail: failed[0]?.detail });
|
|
147
212
|
}
|
|
213
|
+
/** A scripted participant. */
|
|
148
214
|
player(name) {
|
|
149
215
|
return new Fake(this, name);
|
|
150
216
|
}
|
|
217
|
+
/** A custom server event, with its JSON data. */
|
|
151
218
|
custom(name, data, player) {
|
|
152
219
|
return this.dispatch({ type: "custom", name, player, data });
|
|
153
220
|
}
|
|
154
221
|
/** Loads the chunks that cover `box` into the mirror: `block` inside the box, air around it. */
|
|
155
222
|
terrain(box, block, minY = -64, height = 384) {
|
|
156
|
-
const { lo, hi } = (0,
|
|
223
|
+
const { lo, hi } = (0, world_js_1.bounds)(box);
|
|
157
224
|
const out = [];
|
|
158
225
|
for (let cx = lo.x >> 4; cx <= hi.x >> 4; cx++) {
|
|
159
226
|
for (let cz = lo.z >> 4; cz <= hi.z >> 4; cz++) {
|
|
@@ -189,16 +256,33 @@ class Game {
|
|
|
189
256
|
}
|
|
190
257
|
return out;
|
|
191
258
|
}
|
|
259
|
+
/** Loads an all-air chunk column at chunk coordinates (`cx`, `cz`). */
|
|
260
|
+
loadChunk(cx, cz, minY = -64) {
|
|
261
|
+
return this.dispatch({ type: "chunk", x: cx, z: cz, minY, sections: [] });
|
|
262
|
+
}
|
|
263
|
+
/** The engine unloaded a chunk: its blocks and containers leave the mirror. */
|
|
264
|
+
unloadChunk(cx, cz) {
|
|
265
|
+
return this.dispatch({ type: "chunk_unloaded", x: cx, z: cz });
|
|
266
|
+
}
|
|
192
267
|
/** Blocks changed on the server, by anyone or anything. */
|
|
193
268
|
setBlocks(changes) {
|
|
194
269
|
return this.dispatch({ type: "blocks_changed", changes });
|
|
195
270
|
}
|
|
271
|
+
/** The engine filled a box (the plugin's own fill). */
|
|
272
|
+
fillBlocks(from, to, block) {
|
|
273
|
+
return this.dispatch({ type: "blocks_filled", from, to, block });
|
|
274
|
+
}
|
|
275
|
+
/** A non-player entity appeared. */
|
|
196
276
|
spawnEntity(id, type, at, extra = {}) {
|
|
197
277
|
return this.dispatch({ type: "entity_spawned", id, entity: type, at, ...extra });
|
|
198
278
|
}
|
|
279
|
+
/** An entity's reported fields changed. */
|
|
280
|
+
changeEntity(id, fields) {
|
|
281
|
+
return this.dispatch({ type: "entity_changed", id, ...fields });
|
|
282
|
+
}
|
|
199
283
|
/** Entities moved: they arrive with the next tick, so this advances one engine step. */
|
|
200
284
|
moveEntities(moves) {
|
|
201
|
-
return this.dispatch({ type: "tick", serverTick: this.
|
|
285
|
+
return this.dispatch({ type: "tick", serverTick: this.reducerState.tick + this.step, entities: moves });
|
|
202
286
|
}
|
|
203
287
|
/**
|
|
204
288
|
* One engine tick with several samples at once: participants' positions and
|
|
@@ -208,22 +292,23 @@ class Game {
|
|
|
208
292
|
sample(players, entities) {
|
|
209
293
|
return this.dispatch({
|
|
210
294
|
type: "tick",
|
|
211
|
-
serverTick: this.
|
|
295
|
+
serverTick: this.reducerState.tick + this.step,
|
|
212
296
|
players: players.map((p) => ({ participant: true, ...p })),
|
|
213
297
|
entities,
|
|
214
298
|
});
|
|
215
299
|
}
|
|
300
|
+
/** An entity left the world. */
|
|
216
301
|
removeEntity(id, cause = "removed", killer) {
|
|
217
302
|
return this.dispatch({ type: "entity_removed", id, cause, killer });
|
|
218
303
|
}
|
|
219
304
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
* `initial` marks the first snapshot (no handler fires
|
|
305
|
+
* A container's contents as the engine reports them: `items` is the whole content (item id to
|
|
306
|
+
* count), one item per slot. `by` names the player who moved the items when the engine is certain;
|
|
307
|
+
* `initial` marks the first snapshot (no handler fires); `removed` reports the block gone.
|
|
223
308
|
*/
|
|
224
309
|
container(at, items, opts = {}) {
|
|
225
310
|
const key = `${Math.floor(at.x)},${Math.floor(at.y)},${Math.floor(at.z)}`;
|
|
226
|
-
const known = Object.keys(this.
|
|
311
|
+
const known = Object.keys(this.reducerState.containers[key]?.slots ?? {});
|
|
227
312
|
const slots = [];
|
|
228
313
|
let slot = 0;
|
|
229
314
|
for (const [item, count] of Object.entries(items)) {
|
|
@@ -240,9 +325,10 @@ class Game {
|
|
|
240
325
|
type: "container",
|
|
241
326
|
at: { ...at },
|
|
242
327
|
block: opts.block ?? "minecraft:chest",
|
|
243
|
-
slots,
|
|
328
|
+
slots: opts.removed ? [] : slots,
|
|
244
329
|
by: opts.by,
|
|
245
330
|
initial: opts.initial,
|
|
331
|
+
removed: opts.removed,
|
|
246
332
|
});
|
|
247
333
|
}
|
|
248
334
|
/** A game mode change reported by the engine (the `gamemode` event). */
|
|
@@ -253,10 +339,14 @@ class Game {
|
|
|
253
339
|
other(name, sample) {
|
|
254
340
|
return this.dispatch({
|
|
255
341
|
type: "tick",
|
|
256
|
-
serverTick: this.
|
|
342
|
+
serverTick: this.reducerState.tick + this.step,
|
|
257
343
|
players: [{ name, participant: false, ...sample }],
|
|
258
344
|
});
|
|
259
345
|
}
|
|
346
|
+
/** The engine refused one effect. */
|
|
347
|
+
effectFailed(kind, detail, effect, batch) {
|
|
348
|
+
return this.dispatch({ type: "effect_failed", kind, detail, effect, batch });
|
|
349
|
+
}
|
|
260
350
|
/**
|
|
261
351
|
* The engine's answer to a walk: the last one requested, or the last one for
|
|
262
352
|
* `player` (or with `id`) when several are in flight. A walk that was already
|
|
@@ -303,6 +393,24 @@ class Game {
|
|
|
303
393
|
said() {
|
|
304
394
|
return this.effectsAll("announce").map((e) => e.message);
|
|
305
395
|
}
|
|
396
|
+
/** The `game_over` action, once the game ended. */
|
|
397
|
+
result() {
|
|
398
|
+
return this.all("game_over")[0];
|
|
399
|
+
}
|
|
400
|
+
/** Every log line of the run. */
|
|
401
|
+
logs() {
|
|
402
|
+
return this.all("log");
|
|
403
|
+
}
|
|
404
|
+
/** The last value of every metric, global (`""` player key) and per player. */
|
|
405
|
+
metrics() {
|
|
406
|
+
const out = {};
|
|
407
|
+
for (const m of this.all("metric")) {
|
|
408
|
+
const key = m.player ?? "";
|
|
409
|
+
out[key] = out[key] ?? {};
|
|
410
|
+
out[key][m.name] = m.value;
|
|
411
|
+
}
|
|
412
|
+
return out;
|
|
413
|
+
}
|
|
306
414
|
/**
|
|
307
415
|
* The same log through the same reducer instance, from the state this game
|
|
308
416
|
* started with (`init()`, or the checkpoint of `resume`), gives the same final
|
|
@@ -318,22 +426,25 @@ class Game {
|
|
|
318
426
|
s = r.state;
|
|
319
427
|
actions.push(...r.actions);
|
|
320
428
|
}
|
|
321
|
-
assertEqual((0, exports.canonical)(s), (0, exports.canonical)(this.
|
|
429
|
+
assertEqual((0, exports.canonical)(s), (0, exports.canonical)(this.reducerState), "replay: final state differs");
|
|
322
430
|
assertEqual((0, exports.canonical)(actions), (0, exports.canonical)(this.actions), "replay: actions differ");
|
|
323
431
|
}
|
|
432
|
+
/** The state as a JSON string; `Game.resume` continues from it. */
|
|
324
433
|
checkpoint() {
|
|
325
|
-
return JSON.stringify(this.
|
|
434
|
+
return JSON.stringify(this.reducerState);
|
|
326
435
|
}
|
|
436
|
+
/** A game that continues from a checkpoint, as the arena does after a worker restart. */
|
|
327
437
|
static resume(challenge, json) {
|
|
328
438
|
return new Game(challenge, JSON.parse(json));
|
|
329
439
|
}
|
|
440
|
+
/** A fresh attempt id for a vote or give request. */
|
|
330
441
|
nextAttempt() {
|
|
331
442
|
return `attempt:${++this.attempts}`;
|
|
332
443
|
}
|
|
333
444
|
/** The slot a fake player's item occupies: the one the state shows, else the next free one, for this game only. */
|
|
334
445
|
slotFor(name, item) {
|
|
335
|
-
const slots =
|
|
336
|
-
const held = Object.entries(slots).find(([, s]) => s?.
|
|
446
|
+
const slots = this.reducerState.players[name]?.slots ?? {};
|
|
447
|
+
const held = Object.entries(slots).find(([, s]) => s?.id === item);
|
|
337
448
|
if (held)
|
|
338
449
|
return Number(held[0]);
|
|
339
450
|
const mine = this.slots.get(name) ?? new Map();
|
|
@@ -363,50 +474,61 @@ class Fake {
|
|
|
363
474
|
this.g = g;
|
|
364
475
|
this.name = name;
|
|
365
476
|
}
|
|
366
|
-
|
|
367
|
-
|
|
477
|
+
/** One position sample, as one server tick would carry it. */
|
|
478
|
+
moveTo(to) {
|
|
479
|
+
const prev = this.g.reducerState.players[this.name]?.pos;
|
|
368
480
|
const pos = { x: prev?.x ?? 0, z: prev?.z ?? 0, ...to };
|
|
369
|
-
return this.g.dispatch({
|
|
370
|
-
type: "player_moved",
|
|
371
|
-
name: this.name,
|
|
372
|
-
to: pos,
|
|
373
|
-
maxY: extrema?.maxY ?? pos.y,
|
|
374
|
-
minY: extrema?.minY ?? pos.y,
|
|
375
|
-
});
|
|
481
|
+
return this.g.dispatch({ type: "player_moved", name: this.name, to: pos });
|
|
376
482
|
}
|
|
377
|
-
vote
|
|
483
|
+
/** A vote request, as the arena forwards it. `round` stamps the round the arena saw; default: the current one. */
|
|
484
|
+
vote(voteId, option, round) {
|
|
378
485
|
const attemptId = this.g.nextAttempt();
|
|
379
|
-
|
|
486
|
+
const stamped = round ?? this.g.reducerState.votes[voteId]?.round;
|
|
487
|
+
this.g.dispatch({ type: "vote_attempt", attemptId, name: this.name, voteId, option, round: stamped });
|
|
380
488
|
const d = this.g.of("vote_decision").find((x) => x.attemptId === attemptId);
|
|
381
489
|
if (!d)
|
|
382
490
|
throw new Error(`no vote_decision for ${attemptId}`);
|
|
383
491
|
return { accepted: d.accepted, feedback: d.feedback };
|
|
384
492
|
}
|
|
493
|
+
/** A public chat line. */
|
|
385
494
|
says(text) {
|
|
386
495
|
return this.g.dispatch({ type: "chat", from: this.name, text });
|
|
387
496
|
}
|
|
497
|
+
/** An arm swing: a mining or attack attempt. */
|
|
388
498
|
swings(animation = "swing") {
|
|
389
499
|
return this.g.dispatch({ type: "animation", name: this.name, animation });
|
|
390
500
|
}
|
|
501
|
+
/** Damage taken; `attacker` names another participant. */
|
|
391
502
|
hurt(amount, cause, attacker) {
|
|
392
503
|
return this.g.dispatch({ type: "player_damaged", name: this.name, amount, cause, attacker });
|
|
393
504
|
}
|
|
505
|
+
/** A death; `killer` names another participant. */
|
|
394
506
|
dies(cause = "fall", killer) {
|
|
395
507
|
return this.g.dispatch({ type: "player_died", name: this.name, cause, killer });
|
|
396
508
|
}
|
|
509
|
+
/** A respawn after a death. */
|
|
397
510
|
respawns() {
|
|
398
511
|
return this.g.dispatch({ type: "player_respawned", name: this.name });
|
|
399
512
|
}
|
|
513
|
+
/** The player connected. */
|
|
514
|
+
joins() {
|
|
515
|
+
return this.g.dispatch({ type: "player_joined", name: this.name });
|
|
516
|
+
}
|
|
517
|
+
/** The player disconnected. */
|
|
518
|
+
leaves() {
|
|
519
|
+
return this.g.dispatch({ type: "player_left", name: this.name });
|
|
520
|
+
}
|
|
521
|
+
/** An item picked up from the ground. */
|
|
400
522
|
picksUp(item, count = 1, at = { x: 0, y: 0, z: 0 }) {
|
|
401
523
|
return this.g.dispatch({ type: "item_picked_up", name: this.name, item, count, at });
|
|
402
524
|
}
|
|
403
525
|
/** The player's inventory now holds `count` of `item`: one slot per item name, in this game. */
|
|
404
|
-
|
|
526
|
+
setInventory(item, count, meta = {}) {
|
|
405
527
|
const slot = this.g.slotFor(this.name, item);
|
|
406
528
|
return this.g.dispatch({
|
|
407
529
|
type: "inventory",
|
|
408
530
|
name: this.name,
|
|
409
|
-
slots: [count > 0 ? { slot, item, count } : { slot }],
|
|
531
|
+
slots: [count > 0 ? { slot, item, count, ...meta } : { slot }],
|
|
410
532
|
});
|
|
411
533
|
}
|
|
412
534
|
/** Walks into the declared zone (its first corner); the SDK derives the edge. */
|
|
@@ -415,18 +537,21 @@ class Fake {
|
|
|
415
537
|
return this.moveTo({ x: box.from.x + 0.5, y: box.from.y, z: box.from.z + 0.5 });
|
|
416
538
|
}
|
|
417
539
|
/** Walks 100 blocks under the declared zone's first corner. */
|
|
418
|
-
|
|
540
|
+
exits(zone) {
|
|
419
541
|
const box = this.zone(zone);
|
|
420
542
|
return this.moveTo({ x: box.from.x + 0.5, y: box.from.y - 100, z: box.from.z + 0.5 });
|
|
421
543
|
}
|
|
544
|
+
/** A right-click on a block; `item` is what the hand held. */
|
|
422
545
|
uses(block, at, item) {
|
|
423
546
|
return this.g.dispatch({ type: "block_used", name: this.name, at, block, item });
|
|
424
547
|
}
|
|
425
|
-
|
|
426
|
-
|
|
548
|
+
/** Breaks the block: the engine reports the state that was there and what is there now (air by default). */
|
|
549
|
+
breaks(block, at, after = "minecraft:air") {
|
|
550
|
+
return this.g.dispatch({ type: "block_broken", name: this.name, at, block, after });
|
|
427
551
|
}
|
|
428
|
-
|
|
429
|
-
|
|
552
|
+
/** Places the block: the engine reports the placed state and the one it replaced (air by default). */
|
|
553
|
+
places(block, at, replaced = "minecraft:air") {
|
|
554
|
+
return this.g.dispatch({ type: "block_placed", name: this.name, at, block, replaced });
|
|
430
555
|
}
|
|
431
556
|
zone(zone) {
|
|
432
557
|
const zones = this.g.challenge.zones;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness.js","sourceRoot":"","sources":["../../src/test/harness.ts"],"names":[],"mappings":";;;AAuFA,8BAYC;AAnGD,iFAAiF;AACjF,kFAAkF;AAClF,8EAA8E;AAC9E,6EAA6E;AAC7E,qCAAyC;AA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enge } from "../runtime/builder.js";
|
|
2
|
+
import type { Vec3 } from "../runtime/wire.js";
|
|
3
|
+
import type { Game } from "./harness.js";
|
|
4
|
+
/** The reported score per player. */
|
|
5
|
+
export declare function scores(g: Game<AnyChallenge>): Record<string, number>;
|
|
6
|
+
/** Whether `a` is within `blocks` of `b` on each axis, x and z (a square, not a radius; the height is ignored). */
|
|
7
|
+
export declare const near: (a: Vec3, b: Vec3, blocks: number) => boolean;
|
|
8
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/test/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,qCAAqC;AACrC,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEpE;AAED,mHAAmH;AACnH,eAAO,MAAM,IAAI,GAAI,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,QAAQ,MAAM,KAAG,OACO,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.near = void 0;
|
|
4
|
+
exports.scores = scores;
|
|
5
|
+
/** The reported score per player. */
|
|
6
|
+
function scores(g) {
|
|
7
|
+
return Object.fromEntries(Object.entries(g.reducerState.players).map(([name, p]) => [name, p.score]));
|
|
8
|
+
}
|
|
9
|
+
/** Whether `a` is within `blocks` of `b` on each axis, x and z (a square, not a radius; the height is ignored). */
|
|
10
|
+
const near = (a, b, blocks) => Math.abs(a.x - b.x) <= blocks && Math.abs(a.z - b.z) <= blocks;
|
|
11
|
+
exports.near = near;
|
|
12
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/test/helpers.ts"],"names":[],"mappings":";;;AAKA,wBAEC;AAHD,qCAAqC;AACrC,SAAgB,MAAM,CAAC,CAAqB;IAC3C,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvG,CAAC;AAED,mHAAmH;AAC5G,MAAM,IAAI,GAAG,CAAC,CAAO,EAAE,CAAO,EAAE,MAAc,EAAW,EAAE,CACjE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;AADnD,QAAA,IAAI,QAC+C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
@@ -14,5 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
17
|
+
// The test kit: `@kradle/challenges-sdk/test`.
|
|
18
|
+
__exportStar(require("./harness.js"), exports);
|
|
19
|
+
__exportStar(require("./helpers.js"), exports);
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA+C;AAC/C,+CAA6B;AAC7B,+CAA6B"}
|