@team-antioch/sc2-adjutant 0.1.0 → 0.1.1

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.
Files changed (149) hide show
  1. package/README.md +2 -0
  2. package/data/blizzard-baseline.json +3061 -0
  3. package/data/button-hotkeys.json +5722 -0
  4. package/data/game-assets.json +50909 -0
  5. package/data/package-entries.json +32361 -2
  6. package/dist/capture/bank-fixtures.d.ts +13 -0
  7. package/dist/capture/bank-fixtures.js +35 -0
  8. package/dist/capture/bank-snapshots.d.ts +95 -0
  9. package/dist/capture/bank-snapshots.js +302 -0
  10. package/dist/capture/editor-broker-client.d.ts +27 -4
  11. package/dist/capture/editor-broker-client.js +3 -3
  12. package/dist/capture/editor-broker.js +154 -9
  13. package/dist/capture/effect-tour.d.ts +113 -0
  14. package/dist/capture/effect-tour.js +283 -0
  15. package/dist/capture/effect-video.d.ts +74 -0
  16. package/dist/capture/effect-video.js +173 -0
  17. package/dist/capture/exemplar-capture.d.ts +4 -0
  18. package/dist/capture/exemplar-capture.js +4 -1
  19. package/dist/capture/shots.d.ts +6 -1
  20. package/dist/capture/shots.js +1 -1
  21. package/dist/capture/stop-tour.d.ts +3 -1
  22. package/dist/capture/stop-tour.js +1 -1
  23. package/dist/capture/style-pack-captures.d.ts +67 -0
  24. package/dist/capture/style-pack-captures.js +172 -0
  25. package/dist/catalog/stock-catalog.d.ts +8 -0
  26. package/dist/catalog/stock-catalog.js +13 -0
  27. package/dist/cli/capture-exemplars.js +18 -32
  28. package/dist/cli/effect-tour.d.ts +2 -0
  29. package/dist/cli/effect-tour.js +378 -0
  30. package/dist/cli/make-frames.d.ts +1 -0
  31. package/dist/cli/make-frames.js +21 -0
  32. package/dist/cli/sound-mix.d.ts +1 -0
  33. package/dist/cli/sound-mix.js +75 -0
  34. package/dist/cli/study.js +6 -26
  35. package/dist/domain/blueprint-trigger.d.ts +355 -3
  36. package/dist/domain/blueprint-trigger.js +149 -8
  37. package/dist/domain/library-interface.d.ts +50 -29
  38. package/dist/domain/library-interface.js +54 -41
  39. package/dist/domain/mission-blueprint.d.ts +13 -6
  40. package/dist/domain/mission-blueprint.js +6 -0
  41. package/dist/domain/mod-blueprint.d.ts +4 -4
  42. package/dist/host/game-logs.d.ts +63 -0
  43. package/dist/host/game-logs.js +178 -0
  44. package/dist/host/game-ownership.d.ts +37 -0
  45. package/dist/host/game-ownership.js +84 -0
  46. package/dist/host/game-run-report.d.ts +63 -0
  47. package/dist/host/game-run-report.js +119 -0
  48. package/dist/host/known-errors.d.ts +34 -0
  49. package/dist/host/known-errors.js +73 -0
  50. package/dist/init/init-workspace.d.ts +3 -1
  51. package/dist/init/init-workspace.js +10 -1
  52. package/dist/map/convert-mission-triggers.d.ts +115 -7
  53. package/dist/map/convert-mission-triggers.js +527 -47
  54. package/dist/map/editor-changes.d.ts +1 -1
  55. package/dist/map/editor-form.d.ts +5 -0
  56. package/dist/map/editor-form.js +72 -0
  57. package/dist/map/game-packages.d.ts +3 -2
  58. package/dist/map/game-packages.js +5 -2
  59. package/dist/map/kept-references.js +47 -1
  60. package/dist/map/kept-session.js +3 -1
  61. package/dist/map/outline-diff.d.ts +24 -0
  62. package/dist/map/outline-diff.js +95 -0
  63. package/dist/map/outline-trigger.d.ts +7 -0
  64. package/dist/map/outline-trigger.js +29 -20
  65. package/dist/map/ownership-plan.d.ts +6 -2
  66. package/dist/map/ownership-plan.js +1 -1
  67. package/dist/map/package-output.js +13 -8
  68. package/dist/map/tune-kept-triggers.d.ts +7 -0
  69. package/dist/map/tune-kept-triggers.js +33 -6
  70. package/dist/map/write-blueprint-trigger.d.ts +9 -4
  71. package/dist/map/write-blueprint-trigger.js +46 -13
  72. package/dist/map/write-map-package.js +20 -9
  73. package/dist/mcp/capture-jobs.d.ts +2 -0
  74. package/dist/mcp/capture-jobs.js +2 -0
  75. package/dist/mcp/server.d.ts +11 -2
  76. package/dist/mcp/server.js +17 -4
  77. package/dist/mcp/tools/bank-report.d.ts +19 -0
  78. package/dist/mcp/tools/bank-report.js +51 -0
  79. package/dist/mcp/tools/blueprint.js +18 -14
  80. package/dist/mcp/tools/capture.d.ts +4 -0
  81. package/dist/mcp/tools/capture.js +22 -5
  82. package/dist/mcp/tools/catalog.d.ts +1 -1
  83. package/dist/mcp/tools/catalog.js +30 -1
  84. package/dist/mcp/tools/compile.d.ts +1 -1
  85. package/dist/mcp/tools/compile.js +100 -9
  86. package/dist/mcp/tools/editor-handoff.d.ts +4 -1
  87. package/dist/mcp/tools/editor-handoff.js +6 -3
  88. package/dist/mcp/tools/style-pack.d.ts +11 -0
  89. package/dist/mcp/tools/style-pack.js +245 -0
  90. package/dist/mcp/tools/tool-group.d.ts +9 -0
  91. package/dist/mods/button-hotkeys.d.ts +45 -0
  92. package/dist/mods/button-hotkeys.js +185 -0
  93. package/dist/mods/compile-mod.js +19 -5
  94. package/dist/mods/custom-doodads.d.ts +21 -1
  95. package/dist/mods/custom-doodads.js +53 -7
  96. package/dist/mods/data-rules.js +8 -1
  97. package/dist/mods/effective-entry.d.ts +18 -0
  98. package/dist/mods/effective-entry.js +52 -0
  99. package/dist/mods/function-search.js +12 -0
  100. package/dist/mods/library-xml.d.ts +34 -5
  101. package/dist/mods/library-xml.js +94 -22
  102. package/dist/mods/sound-mix.d.ts +92 -0
  103. package/dist/mods/sound-mix.js +195 -0
  104. package/dist/plugins/check-workspace.js +22 -3
  105. package/dist/plugins/plugin-api.d.ts +59 -5
  106. package/dist/plugins/plugin-api.js +6 -0
  107. package/dist/plugins/plugin-sdk.d.ts +13 -1
  108. package/dist/plugins/plugin-sdk.js +16 -1
  109. package/dist/plugins/plugin-sources.js +1 -0
  110. package/dist/plugins/registry.d.ts +4 -0
  111. package/dist/plugins/registry.js +6 -2
  112. package/dist/plugins/workspace.d.ts +5 -0
  113. package/dist/plugins/workspace.js +10 -2
  114. package/dist/study/blizzard-baseline.d.ts +76 -0
  115. package/dist/study/blizzard-baseline.js +137 -0
  116. package/dist/study/exemplar-report.d.ts +71 -0
  117. package/dist/study/exemplar-report.js +163 -0
  118. package/dist/study/find-places.d.ts +127 -0
  119. package/dist/study/find-places.js +306 -0
  120. package/dist/study/load-map-package.d.ts +3 -0
  121. package/dist/study/load-map-package.js +11 -0
  122. package/dist/study/map-study.d.ts +1 -0
  123. package/dist/study/map-study.js +3 -0
  124. package/dist/study/measure-lighting.d.ts +6 -0
  125. package/dist/study/measure-lighting.js +1 -1
  126. package/dist/study/measures.d.ts +225 -0
  127. package/dist/study/measures.js +366 -0
  128. package/dist/study/scaffold-style-pack.d.ts +58 -0
  129. package/dist/study/scaffold-style-pack.js +261 -0
  130. package/dist/study/study-exemplars.d.ts +67 -0
  131. package/dist/study/study-exemplars.js +133 -0
  132. package/dist/triggers/blueprint-triggers.d.ts +71 -11
  133. package/dist/triggers/blueprint-triggers.js +403 -48
  134. package/dist/triggers/kept-trigger-galaxy.d.ts +29 -0
  135. package/dist/triggers/kept-trigger-galaxy.js +103 -7
  136. package/dist/triggers/splice-map-script.d.ts +2 -0
  137. package/dist/triggers/splice-map-script.js +309 -8
  138. package/dist/triggers/write-triggers-xml.js +20 -5
  139. package/dist/ui/frame-path-check.d.ts +43 -4
  140. package/dist/ui/frame-path-check.js +121 -13
  141. package/dist/ui/frame-paths.d.ts +21 -1
  142. package/dist/ui/frame-paths.js +26 -6
  143. package/dist/ui/toast.d.ts +4 -5
  144. package/dist/ui/toast.js +6 -10
  145. package/examples/example-campaign/README.md +27 -0
  146. package/examples/example-campaign/missions/ashfall-relay/blueprint.json +11 -1
  147. package/examples/example-campaign/missions/ashfall-relay/triggers/ash-tremors.json +69 -0
  148. package/examples/example-campaign/missions/ashfall-relay/triggers/start-ash-tremors.json +31 -0
  149. package/package.json +3 -3
@@ -8,8 +8,10 @@
8
8
  // it has hung up (one of a merged tour's clients going isn't enough). It exits after `idleMs`
9
9
  // with nothing to do. The display is kept awake by editor.captureTour itself while a tour runs.
10
10
  // It runs the other Editor actions that click menus (open, Test Document, save) as jobs too, in
11
- // the same queue; after a Test Document it holds the queue until that game quits (game.running),
12
- // since a capture quits any game it finds. An editor job marked ifIdle is refused while anything
11
+ // the same queue; after a Test Document it holds the queue until that game quits (game.list, else
12
+ // game.running). It records each game a job starts, by pid and start time: a capture's is the
13
+ // tool's, quit by pid and gracefully once the job ends or fails (game.quit); a Test Document's is the
14
+ // author's to play, never quit, and a capture refuses while any game it didn't start runs. An editor job marked ifIdle is refused while anything
13
15
  // runs or waits, with what that is, for test_mission, which can't wait out a capture.
14
16
  // Its log has each job's start, end and progress lines, so one job's "running" always follows the
15
17
  // last one's "done" or "failed": the record of what the Editor was doing when a capture went wrong.
@@ -19,12 +21,14 @@ import net from "node:net";
19
21
  import path from "node:path";
20
22
  import { hostContext } from "../host/machine-config.js";
21
23
  import { CAPTURE_MAPS_FOLDER } from "../plugins/plugin-api.js";
24
+ import { discardBankRun, finishBankRun, restoreBankRun, snapshotBanks, unrestoredFixtureRun } from "./bank-snapshots.js";
22
25
  import { makeCaptureCopy, TOUR_BANK } from "./capture-copy.js";
23
26
  import { BROKER_PROTOCOL, connect, isNamedPipe, readLines, } from "./editor-broker-client.js";
24
27
  /** How long a broker waits with nothing to do before it exits: 10 minutes. */
25
28
  export const BROKER_IDLE_MS = 10 * 60 * 1000;
26
29
  /** The most stops one tour holds (makeCaptureCopy's limit), so the most a merged tour takes. */
27
30
  const MAX_TOUR_STOPS = 1024;
31
+ const sameGame = (a, b) => a.pid === b.pid && a.startedAt === b.startedAt;
28
32
  /**
29
33
  * Starts a broker on `socketPath`, or resolves null when another broker answers there: of two
30
34
  * started at once, one binds the socket and the other finds it answering. A socket file no broker
@@ -42,6 +46,8 @@ export async function startEditorBroker(options) {
42
46
  const hungUp = new Set();
43
47
  /** Set while the queue waits for the game a Test Document job started to quit. */
44
48
  let holding = false;
49
+ /** Every game a job started that may still run, by who owns it. Only a tool's is ever quit. */
50
+ let games = [];
45
51
  const holdPollMs = options.holdPollMs ?? 5000;
46
52
  let lastError = null;
47
53
  let pumping = false;
@@ -127,13 +133,51 @@ export async function startEditorBroker(options) {
127
133
  return `The Editor is busy (Editor Broker pid ${process.pid}): ${what}${waiting}. npm run capture-shots -- --status shows the queue; try again once it's done, or cancel a capture no one needs (capture_shots({ job, cancel: true })).`;
128
134
  }
129
135
  function status() {
130
- return { pid: process.pid, ...(options.script ? { script: options.script } : {}), running: running ? running.map(summary) : null, queue: queue.map(summary), lastError };
136
+ return {
137
+ pid: process.pid,
138
+ ...(options.script ? { script: options.script } : {}),
139
+ running: running ? running.map(summary) : null,
140
+ queue: queue.map(summary),
141
+ games: games.map(({ pid, owner, job }) => ({ pid, owner, job })),
142
+ lastError,
143
+ };
144
+ }
145
+ /** The running games, or null when the host can't list them. Records of games that have gone are dropped. */
146
+ async function listGames() {
147
+ if (!host.has("game.list"))
148
+ return null;
149
+ try {
150
+ const list = await host.run("game.list", {});
151
+ games = games.filter((record) => list.some((each) => sameGame(each, record.game)));
152
+ return list;
153
+ }
154
+ catch (error) {
155
+ log(`couldn't list the games: ${error.message}`);
156
+ return null;
157
+ }
158
+ }
159
+ /** Quits the games a capture started, by pid and start time, gracefully; an author's test game is never touched. */
160
+ async function quitToolGames() {
161
+ for (const record of games.filter((each) => each.owner === "tool")) {
162
+ try {
163
+ const how = await host.run("game.quit", { game: record.game, log: (line) => log(`quitting game ${record.pid}: ${line}`) });
164
+ log(`game ${record.pid} of job ${record.job}: ${how}`);
165
+ }
166
+ catch (error) {
167
+ lastError = { job: record.job, message: `quitting game ${record.pid}: ${error.message}`, at: new Date().toISOString() };
168
+ log(lastError.message);
169
+ }
170
+ games = games.filter((each) => each !== record);
171
+ }
131
172
  }
132
173
  async function closeCopies(why) {
133
174
  if (!host.has("editor.closeCaptureCopies"))
134
175
  return;
176
+ const own = games.filter((record) => record.owner === "tool").map((record) => record.game);
135
177
  try {
136
- await host.run("editor.closeCaptureCopies", { log: (line) => log(`closing copies ${why}: ${line}`) });
178
+ await host.run("editor.closeCaptureCopies", { log: (line) => log(`closing copies ${why}: ${line}`), ...(own.length ? { games: own } : {}) });
179
+ // Quit by it, or gone: the tool's records are done either way.
180
+ games = games.filter((record) => record.owner !== "tool");
137
181
  }
138
182
  catch (error) {
139
183
  lastError = { message: `closing capture copies ${why}: ${error.message}`, at: new Date().toISOString() };
@@ -173,7 +217,18 @@ export async function startEditorBroker(options) {
173
217
  continue;
174
218
  }
175
219
  try {
176
- const results = await runBatch(host, batch, (line) => log(`${head.id}: ${line}`), signal);
220
+ // A game an earlier job left running that was a capture's is quit first; any other game is left for the host to refuse.
221
+ await listGames();
222
+ await quitToolGames();
223
+ const startedAt = new Date().toISOString();
224
+ const started = [];
225
+ const ran = await runBatch(host, batch, (line) => log(`${head.id}: ${line}`), signal, (game) => {
226
+ started.push(game);
227
+ games.push({ game, pid: game.pid, owner: "tool", job: head.id });
228
+ log(`${head.id}: started game ${game.pid}, the tool's to quit`);
229
+ });
230
+ const results = ran.map((result) => ({ ...result, games: started, startedAt }));
231
+ await quitToolGames();
177
232
  log(`done ${ids}: ${results.map((result) => result.frames).join(" + ")} frames, ${results[0].end}`);
178
233
  batch.forEach((entry, i) => entry.send({ type: "done", result: results[i] }));
179
234
  }
@@ -189,6 +244,7 @@ export async function startEditorBroker(options) {
189
244
  entry.send({ type: "failed", message });
190
245
  // The copy is closed unsaved even when the tour failed before it could close it.
191
246
  await closeCopies(`after job ${head.id} ${signal.aborted ? "was cancelled" : "failed"}`);
247
+ await quitToolGames();
192
248
  }
193
249
  for (const entry of batch)
194
250
  hungUp.delete(entry);
@@ -204,25 +260,61 @@ export async function startEditorBroker(options) {
204
260
  /** Runs one Editor action; after a Test Document, holds the queue until its game quits. */
205
261
  async function runEditorJob(entry, job) {
206
262
  const record = (line) => log(`${entry.id}: ${line}`);
263
+ let snapshot;
264
+ try {
265
+ snapshot = job.action === "editor.testDocument" ? await snapshotBanksBefore(job.source, record, job.bankFixture) : undefined;
266
+ }
267
+ catch (error) {
268
+ // A bank fixture that can't go in, or the author's banks not yet back from the last one: the game doesn't start.
269
+ const message = error instanceof Error ? error.message : String(error);
270
+ log(`failed ${entry.id}: ${message}`);
271
+ entry.send({ type: "failed", message });
272
+ return;
273
+ }
274
+ const before = job.action === "editor.testDocument" ? await listGames() : null;
207
275
  try {
208
276
  await host.run(job.action, { mapPath: job.source, ...(job.seconds !== undefined ? { seconds: job.seconds } : {}) });
209
277
  }
210
278
  catch (error) {
211
279
  const message = error instanceof Error ? error.message : String(error);
212
280
  log(`failed ${entry.id}: ${message}`);
281
+ // The game never started, so a fixture's banks must not stay in the folder; a run on the author's own banks changed nothing.
282
+ if (snapshot?.run.fixture !== undefined)
283
+ await restoreBankRun(snapshot.cacheDir, snapshot.run).catch((restoreError) => record(`couldn't put the author's banks back: ${restoreError instanceof Error ? restoreError.message : String(restoreError)}; bank_changes will try again`));
284
+ else if (snapshot)
285
+ await discardBankRun(snapshot.cacheDir, snapshot.run.id).catch(() => undefined);
213
286
  entry.send({ type: "failed", message });
214
287
  return;
215
288
  }
216
289
  log(`done ${entry.id}: ${job.action}`);
217
290
  entry.send({ type: "done", result: null });
218
- if (job.action !== "editor.testDocument" || !host.has("game.running"))
291
+ if (job.action !== "editor.testDocument")
292
+ return;
293
+ // The games this Test Document started are the author's to play: recorded as theirs, never quit.
294
+ const after = before ? await listGames() : null;
295
+ const started = before && after ? after.filter((game) => !before.some((each) => sameGame(each, game))) : [];
296
+ for (const game of started) {
297
+ games.push({ game, pid: game.pid, owner: "author", job: entry.id });
298
+ record(`game ${game.pid} started: the author's, never quit by the broker`);
299
+ }
300
+ if (!before && !host.has("game.running"))
219
301
  return;
302
+ if (before && started.length === 0) {
303
+ // No game of its own to wait for (it never started, or already quit): the banks are as the run left them.
304
+ if (snapshot)
305
+ await recordBankChanges(snapshot, record);
306
+ return;
307
+ }
308
+ const stillPlaying = async () => (before ? ((await listGames()) ?? []).some((game) => started.some((each) => sameGame(each, game))) : host.run("game.running", {}));
220
309
  holding = true;
221
310
  record("holding the queue until the test game quits");
222
311
  try {
223
- while (!closing && (await host.run("game.running", {})))
312
+ while (!closing && (await stillPlaying()))
224
313
  await new Promise((resolve) => setTimeout(resolve, holdPollMs));
225
314
  record("the test game quit");
315
+ // A closing broker leaves a fixture run `running`: bank_changes puts the author's banks back once the game has quit.
316
+ if (snapshot && !closing)
317
+ await recordBankChanges(snapshot, record);
226
318
  }
227
319
  catch (error) {
228
320
  // A host that can't tell any more doesn't hold the queue for ever.
@@ -230,6 +322,52 @@ export async function startEditorBroker(options) {
230
322
  }
231
323
  finally {
232
324
  holding = false;
325
+ games = games.filter((record) => record.job !== entry.id);
326
+ }
327
+ }
328
+ /**
329
+ * Copies the game's Banks folder into the cache before a test game starts (#54), when the host
330
+ * names it. A snapshot that fails never stops a test on the author's own banks: the run just goes
331
+ * unreported. With a `fixture` (#55) it does, since the game would play on the wrong banks, and so
332
+ * does a fixture run of an earlier test whose banks haven't been put back: its snapshot, not the
333
+ * folder, holds the author's banks. The fixture's banks go in once the snapshot is taken.
334
+ */
335
+ async function snapshotBanksBefore(source, record, fixture) {
336
+ if (!host.has("game.banksDir")) {
337
+ if (fixture)
338
+ throw new Error(`Not played: bank fixture ${fixture.name} needs the Host Adapter to name the game's Banks folder (game.banksDir)`);
339
+ return undefined;
340
+ }
341
+ try {
342
+ const cacheDir = hostContext(host.machine).requirePath("cacheDir");
343
+ const earlier = await unrestoredFixtureRun(cacheDir);
344
+ if (earlier) {
345
+ // Put back now if its game is known to have quit; else the folder can't be trusted as the author's.
346
+ const quit = host.has("game.running") && !(await host.run("game.running", {}).catch(() => true));
347
+ if (quit)
348
+ await finishBankRun(cacheDir, earlier);
349
+ else
350
+ throw new BankFixtureError(`Not played: the last test game ran on the bank fixture ${earlier.fixture}, and the author's own banks aren't back in the Banks folder yet. Quit that game, then call bank_changes${host.has("game.running") ? "" : " with rollbackAll"} to put them back.`);
351
+ }
352
+ const run = await snapshotBanks(cacheDir, await host.run("game.banksDir", {}), source, new Date(), fixture);
353
+ record(`snapshot of the banks ${run.id}${fixture ? `, bank fixture ${fixture.name} copied in` : ""}`);
354
+ return { cacheDir, run };
355
+ }
356
+ catch (error) {
357
+ if (fixture || error instanceof BankFixtureError)
358
+ throw error;
359
+ record(`no banks snapshot: ${error.message}`);
360
+ return undefined;
361
+ }
362
+ }
363
+ /** Once the test game has quit, records which banks it changed; bank_changes reports them. */
364
+ async function recordBankChanges(snapshot, record) {
365
+ try {
366
+ const finished = await finishBankRun(snapshot.cacheDir, snapshot.run);
367
+ record(finished.changes.length === 0 ? "the test game changed no banks" : `the test game changed ${finished.changes.length} bank${finished.changes.length === 1 ? "" : "s"}: ${finished.changes.map((change) => `${change.bank} (${change.status})`).join(", ")}`);
368
+ }
369
+ catch (error) {
370
+ record(`couldn't record the banks the test game changed: ${error.message}`);
233
371
  }
234
372
  }
235
373
  function close() {
@@ -275,7 +413,7 @@ function takeMerging(head, queue) {
275
413
  }
276
414
  const stopCount = (job) => (job.kind === "tour" ? (job.copy.stops?.length ?? 0) : 0);
277
415
  /** Runs one tour for the batch's jobs, all alike but their stops; each job's result. Its progress lines go to each job's client and to `record`, the broker's log. */
278
- async function runBatch(host, batch, record, signal) {
416
+ async function runBatch(host, batch, record, signal, onGameStarted) {
279
417
  const head = batch[0];
280
418
  const { job } = head;
281
419
  if (job.kind === "editor")
@@ -318,16 +456,20 @@ async function runBatch(host, batch, record, signal) {
318
456
  else
319
457
  mapPath = job.source;
320
458
  }
459
+ // A merged tour's video would be one recording of every job's stops; only a tour of one job records.
460
+ const { video, ...settings } = job.settings;
321
461
  const request = {
322
462
  mapPath,
323
463
  bank,
324
464
  outputDir,
325
- ...job.settings,
465
+ ...settings,
466
+ ...(video && !merged ? { video } : {}),
326
467
  frameDigits,
327
468
  ...(writeMap ? { writeMap } : {}),
328
469
  ...(job.kind === "map" && job.attach ? { attach: true } : {}),
329
470
  log,
330
471
  signal,
472
+ onGameStarted,
331
473
  };
332
474
  let results;
333
475
  let end;
@@ -347,6 +489,9 @@ async function runBatch(host, batch, record, signal) {
347
489
  return results.map((each) => (copy ? { ...each, copy } : each));
348
490
  }
349
491
  /** A merged tour's job: tours only merge with tours. */
492
+ /** The banks aren't in a state to start a test game on. */
493
+ class BankFixtureError extends Error {
494
+ }
350
495
  const capture = (entry) => entry.job;
351
496
  /** Moves a merged tour's frames, and its stops.txt lines, to each job's folder, numbered from 1 for each job. */
352
497
  async function splitFrames(scratch, batch, end) {
@@ -0,0 +1,113 @@
1
+ import type { M3Sequence } from "../catalog/m3-sequences.js";
2
+ /** The bank the effect tour saves, with int key `stop`. */
3
+ export declare const EFFECT_TOUR_BANK = "FxTour";
4
+ /** The tour's Custom Script element and its init function. */
5
+ export declare const EFFECT_TOUR_SCRIPT_ID = "F7700001";
6
+ export declare const EFFECT_TOUR_INIT = "FxTour_Init";
7
+ type Vec3 = readonly [number, number, number];
8
+ /** One effect model to film: its storage path, its animations and its bounds (cells, in its own frame). */
9
+ export type TourEffect = {
10
+ readonly file: string;
11
+ readonly sequences: readonly M3Sequence[];
12
+ readonly min: Vec3;
13
+ readonly max: Vec3;
14
+ };
15
+ /** What a frame shows. */
16
+ export type EffectShotLabel = "birth" | "stand" | "moving" | "after-destroy" | "death";
17
+ /** A frame the tour takes: its stop number (the bank's `stop`, and the frame's file name), the effect and what it shows. */
18
+ export type EffectShot = {
19
+ readonly stop: number;
20
+ readonly effect: number;
21
+ readonly file: string;
22
+ readonly label: EffectShotLabel;
23
+ };
24
+ /** How one effect is filmed: seconds of game time, and the camera. Zero skips a part. */
25
+ export type EffectPlan = {
26
+ /** Half its Birth, when the birth frame is taken; then the rest of it. */
27
+ readonly birth: number;
28
+ /** Into Stand when the stand frame is taken. */
29
+ readonly standShot: number;
30
+ /** How long the host moves before the moving frame; 0 for an effect too short to move. */
31
+ readonly move: number;
32
+ /** How far it moves in that time, in cells. */
33
+ readonly moveCells: number;
34
+ /** Half its Death, when the death frame is taken; 0 when it has none. */
35
+ readonly death: number;
36
+ /**
37
+ * An animation to play as soon as it's made: the only one a model has when it has neither Birth
38
+ * nor Stand (an impact with only Death), which the game's bracket wouldn't play; "" for none.
39
+ */
40
+ readonly play: string;
41
+ /** The camera: distance (cells) and the height it looks at, above the pad. */
42
+ readonly distance: number;
43
+ readonly height: number;
44
+ /** Each frame's stop, 0 when the frame isn't taken. */
45
+ readonly stops: Readonly<Record<EffectShotLabel, number>>;
46
+ };
47
+ /** The camera's pitch: three quarters from above, as effects are seen in play but with more of their height. */
48
+ export declare const EFFECT_PITCH = 40;
49
+ /** How much more than the effect's bounds the frame holds: bounds seldom cover all the particles. */
50
+ export declare const FRAME_MARGIN = 1.3;
51
+ /**
52
+ * Plans one effect: which frames it gets and when. The game plays a generic model actor's
53
+ * animations as a bracket, Birth, then Stand (looping), then Death once the bracket is stopped,
54
+ * so the plan follows the animations the file has:
55
+ * - `birth` half way through Birth, when it has one;
56
+ * - `stand` a second into a looping Stand, or half way through one that plays once (a one-shot);
57
+ * - `moving` after the host has moved sideways for a second, when Stand loops or lasts long enough;
58
+ * - `after-destroy` half a second after a plain Destroy, which shows particles left in the world;
59
+ * - `death` half way through Death, on a fresh copy whose bracket is stopped, when it has one.
60
+ * `firstStop` is the first stop number; the plan numbers its frames on from it.
61
+ */
62
+ export declare function planEffect(effect: TourEffect, firstStop: number): EffectPlan;
63
+ /** A batch of effects planned for one map: each effect's CModel id, its plan and every frame in stop order. */
64
+ export type EffectBatch = {
65
+ readonly effects: readonly TourEffect[];
66
+ readonly ids: readonly string[];
67
+ readonly plans: readonly EffectPlan[];
68
+ readonly shots: readonly EffectShot[];
69
+ };
70
+ /** The map-local CModel id of a batch's `n`th effect. */
71
+ export declare const effectModelId: (n: number) => string;
72
+ /** Plans a batch: its effects' plans, numbered from stop 1. */
73
+ export declare function planEffectBatch(effects: readonly TourEffect[]): EffectBatch;
74
+ /** About how long a batch takes in game, in seconds, after the game starts. The game's waits run at real speed in Test Document: the test batch (2026-11-23) took 143 s against 117 planned. */
75
+ export declare function batchSeconds(batch: EffectBatch, options?: Pick<EffectTourOptions, "hold">): number;
76
+ /** `--batches`: one batch (`3`) or a range (`3-5`); every batch when unset. */
77
+ export declare function batchRange(range: string | undefined): [number, number];
78
+ /** The map-local ModelData: one CModel per effect file. */
79
+ export declare function effectModelData(batch: EffectBatch): string;
80
+ /** Seconds of real time each frame is held for the screenshot, by default. */
81
+ export declare const DEFAULT_HOLD = 1.5;
82
+ export type EffectTourOptions = {
83
+ /** Where on the map the pad is, in cells. */
84
+ readonly pad?: readonly [number, number];
85
+ /** The unit the effects are attached to; a Marine by default, which also shows their scale. */
86
+ readonly host?: string;
87
+ /** The host player's colour index, for the parts that take team colour; 8 (light pink) by default. */
88
+ readonly teamColor?: number;
89
+ /** The Light the batch is filmed in; the tileset's own when unset. */
90
+ readonly lighting?: string;
91
+ /** Seconds of real time each frame is held for the screenshot. */
92
+ readonly hold?: number;
93
+ /**
94
+ * Hold the game still while a frame is taken (Set Global Time Scale 0). Off by default: in the
95
+ * test run (2026-11-23) the game wrote no bank while held, so the capture missed 15 of 38 frames.
96
+ */
97
+ readonly freeze?: boolean;
98
+ /**
99
+ * The capture records video as well: once the pad is reset for an effect, the tour saves int key
100
+ * `mark` (the effect's number from 1), which the Host Adapter notes in the video's timeline, and
101
+ * attaches the effect a second later, so the frames of a burst over before any screenshot can
102
+ * be found in it (effect-video.ts). It waits 12 s before the first effect, not 3, for the
103
+ * recording to start.
104
+ */
105
+ readonly video?: boolean;
106
+ };
107
+ /**
108
+ * The batch's Galaxy: hide the UI, make the host, then film each effect in turn on the pad. Each
109
+ * frame is announced by saving bank "FxTour" with key `stop`, held for the screenshot, and the
110
+ * tour ends with stop -1. Waits for animations are in game time, waits for screenshots in real time.
111
+ */
112
+ export declare function effectTourScript(batch: EffectBatch, options?: EffectTourOptions): string;
113
+ export {};