@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
@@ -0,0 +1,366 @@
1
+ // Lesson-neutral measures of a map's look: numbers any Style Pack's maps can be compared on, named by
2
+ // what they measure and carrying no rule or threshold of any pack's. The Antioch pack's lessons
3
+ // script reads them for its Design Lessons, the Blizzard baseline (data/blizzard-baseline.json)
4
+ // holds them for every campaign mission, and a pack's consistency report compares the two.
5
+ //
6
+ // Definitions: "visible" doodads leave out helpers (point and spot lights, curtains, blockers,
7
+ // placement markers). The main level is the whole cliff level with the most playable cells, ramps
8
+ // left out. A level's cells are its playable, non-ramp cells.
9
+ import { EMPTY_CATALOG } from "../catalog/catalog-layer.js";
10
+ import { getTilesetSky, SKY_TAGS } from "../catalog/tileset-sky.js";
11
+ import { xmlElement, xmlElements } from "../map/xml-elements.js";
12
+ import { studyDoodads } from "./measure-doodads.js";
13
+ import { lightingCalls } from "./measure-lighting.js";
14
+ import { round } from "./stats.js";
15
+ import { buildTerrainGrid, cellIndexAt } from "./terrain-grid.js";
16
+ const HELPER = /^LightOmni|^LightSpot|Curtain|Blocker|PlacementDoodad|^PathingBlocker|^SightBlocker/i;
17
+ /** Whether a doodad type is a helper a player doesn't see as dressing: a light, curtain, blocker or marker. */
18
+ export const isHelperDoodad = (type) => HELPER.test(type);
19
+ /** `catalog`: whose doodads it knows, for their kinds; a map studied alone uses the game's. */
20
+ export function measureInput(map, catalog = EMPTY_CATALOG) {
21
+ const grid = buildTerrainGrid(map);
22
+ const doodads = studyDoodads(map, catalog);
23
+ const levelCells = new Map();
24
+ let playable = 0;
25
+ for (let i = 0; i < grid.width * grid.height; i++) {
26
+ if (!grid.isPlayable[i] || grid.isRamp[i])
27
+ continue;
28
+ playable++;
29
+ levelCells.set(grid.level[i], (levelCells.get(grid.level[i]) ?? 0) + 1);
30
+ }
31
+ if (!playable)
32
+ throw new Error(`${map.dir}: no playable ground to measure`);
33
+ const levels = [...levelCells.keys()].sort((a, b) => a - b);
34
+ const main = [...levelCells].sort((a, b) => b[1] - a[1])[0][0];
35
+ return { map, grid, doodads, visible: doodads.filter((d) => !isHelperDoodad(d.type)), dominant: dominantTextures(grid), levels, levelCells, playable, main };
36
+ }
37
+ /** The texture with the largest share of each cell (the first layer on a tie). */
38
+ export function dominantTextures(grid) {
39
+ const n = grid.width * grid.height;
40
+ const out = new Array(n);
41
+ for (let i = 0; i < n; i++) {
42
+ let best = -1;
43
+ let name = "";
44
+ for (let l = 0; l < 8; l++) {
45
+ const s = grid.layerShare[i * 8 + l];
46
+ if (s > best)
47
+ [best, name] = [s, grid.layerTexture[i * 8 + l]];
48
+ }
49
+ out[i] = name;
50
+ }
51
+ return out;
52
+ }
53
+ const cellOf = (input, d) => cellIndexAt(input.grid, d.position.x, d.position.y);
54
+ /** Each level's top texture by dominant cells, its share of the level, and the level's share of the playable ground. */
55
+ export function topTextureByLevel(input) {
56
+ const { grid, dominant, levelCells, playable } = input;
57
+ return input.levels.map((level) => {
58
+ const counts = new Map();
59
+ for (let i = 0; i < grid.width * grid.height; i++) {
60
+ if (grid.isPlayable[i] && !grid.isRamp[i] && grid.level[i] === level)
61
+ counts.set(dominant[i], (counts.get(dominant[i]) ?? 0) + 1);
62
+ }
63
+ const [texture, count] = [...counts].sort((a, b) => b[1] - a[1])[0];
64
+ return { level, texture, share: count / levelCells.get(level), cellShare: levelCells.get(level) / playable };
65
+ });
66
+ }
67
+ /** The visible doodads standing on playable ground. */
68
+ export function visibleOnPlayable(input) {
69
+ return input.visible.filter((d) => input.grid.isPlayable[cellOf(input, d)]);
70
+ }
71
+ /**
72
+ * A level's share of the visible doodads against its share of the ground: 1 is as dense as the
73
+ * map, below 1 sparser. NaN on a map with no visible doodads.
74
+ */
75
+ export function doodadDensityRatio(input, level) {
76
+ const { grid, visible, levelCells, playable } = input;
77
+ const onLevel = visible.filter((d) => grid.level[cellOf(input, d)] === level && grid.isPlayable[cellOf(input, d)]).length;
78
+ return onLevel / visible.length / (levelCells.get(level) / playable);
79
+ }
80
+ /** An area the size of one capture frame, in cells. */
81
+ export const FRAME_AREA = { width: 18, height: 12 };
82
+ /**
83
+ * Tiles the map with frame-sized areas from its south-west corner, keeps those mostly on the main
84
+ * level, and counts a texture as in an area once it gives 0.5% of the area's main-level cells.
85
+ */
86
+ export function frameAreaTexturing(input) {
87
+ const { grid, main, visible } = input;
88
+ const { width: W, height: H } = grid;
89
+ const { width: FW, height: FH } = FRAME_AREA;
90
+ let areas = 0;
91
+ let singleTexture = 0;
92
+ const doodads = { single: [0, 0, 0], mixed: [0, 0, 0] };
93
+ for (let y0 = 0; y0 + FH <= H; y0 += FH) {
94
+ for (let x0 = 0; x0 + FW <= W; x0 += FW) {
95
+ let onMain = 0;
96
+ const share = new Map();
97
+ for (let y = y0; y < y0 + FH; y++) {
98
+ for (let x = x0; x < x0 + FW; x++) {
99
+ const i = y * W + x;
100
+ if (!grid.isPlayable[i] || grid.isRamp[i] || grid.level[i] !== main)
101
+ continue;
102
+ onMain++;
103
+ for (let l = 0; l < 8; l++) {
104
+ const s = grid.layerShare[i * 8 + l];
105
+ if (s > 0)
106
+ share.set(grid.layerTexture[i * 8 + l], (share.get(grid.layerTexture[i * 8 + l]) ?? 0) + s);
107
+ }
108
+ }
109
+ }
110
+ if (onMain < 0.8 * FW * FH)
111
+ continue;
112
+ areas++;
113
+ const present = [...share.values()].filter((s) => s / onMain >= 0.005).length;
114
+ const kind = present <= 1 ? "single" : "mixed";
115
+ if (kind === "single")
116
+ singleTexture++;
117
+ const inArea = visible.filter(({ position: { x, y } }) => x >= x0 && x < x0 + FW && y >= y0 && y < y0 + FH);
118
+ doodads[kind][0]++;
119
+ doodads[kind][1] += inArea.filter((d) => d.kind !== "decal").length;
120
+ doodads[kind][2] += inArea.filter((d) => d.kind === "decal").length;
121
+ }
122
+ }
123
+ return { areas, singleTexture, doodads };
124
+ }
125
+ /** A layer counts as in a cell's blend once it gives this share of the cell. */
126
+ const BLEND_PRESENT = 0.1;
127
+ export function blendPlacement(input) {
128
+ const { grid, dominant } = input;
129
+ const { width: W, height: H } = grid;
130
+ const border = new Uint8Array(W * H);
131
+ let borderEdges = 0;
132
+ for (let y = 0; y < H; y++) {
133
+ for (let x = 0; x < W; x++) {
134
+ const i = y * W + x;
135
+ for (const [nx, ny] of [[x + 1, y], [x, y + 1]]) {
136
+ if (nx >= W || ny >= H || dominant[ny * W + nx] === dominant[i])
137
+ continue;
138
+ border[i] = border[ny * W + nx] = 1;
139
+ if (grid.isPlayable[i] && grid.isPlayable[ny * W + nx])
140
+ borderEdges++;
141
+ }
142
+ }
143
+ }
144
+ let cells = 0;
145
+ let singleTexture = 0;
146
+ let blended = 0;
147
+ let blendedNearBorder = 0;
148
+ for (let y = 0; y < H; y++) {
149
+ for (let x = 0; x < W; x++) {
150
+ const i = y * W + x;
151
+ if (!grid.isPlayable[i])
152
+ continue;
153
+ cells++;
154
+ let present = 0;
155
+ for (let l = 0; l < 8; l++)
156
+ if (grid.layerShare[i * 8 + l] >= BLEND_PRESENT)
157
+ present++;
158
+ if (present <= 1) {
159
+ singleTexture++;
160
+ continue;
161
+ }
162
+ blended++;
163
+ let near = false;
164
+ for (let dy = -2; dy <= 2 && !near; dy++) {
165
+ for (let dx = -2; dx <= 2 && !near; dx++) {
166
+ const nx = x + dx;
167
+ const ny = y + dy;
168
+ if (nx >= 0 && ny >= 0 && nx < W && ny < H && border[ny * W + nx])
169
+ near = true;
170
+ }
171
+ }
172
+ if (near)
173
+ blendedNearBorder++;
174
+ }
175
+ }
176
+ return { cells, singleTexture, blended, blendedNearBorder, borderEdges };
177
+ }
178
+ /** Doodad kinds a yaw-snapping measure groups: natural props, built props and decals. */
179
+ export const PROP_KINDS = { natural: ["rock", "tree", "foliage"], built: ["ruin", "other"], decal: ["decal"] };
180
+ /** Whether a yaw (radians) sits within a degree of a 45-degree step. */
181
+ export function isSnappedYaw(yaw) {
182
+ const deg = ((((yaw * 180) / Math.PI) % 45) + 45) % 45;
183
+ return deg < 1 || deg > 44;
184
+ }
185
+ /** The share of `doodads` on a 45-degree step; null when there are none. */
186
+ export function snappedShare(doodads) {
187
+ return doodads.length ? doodads.filter((d) => isSnappedYaw(d.yaw)).length / doodads.length : null;
188
+ }
189
+ /** The visible doodads of one group of PROP_KINDS. */
190
+ export function propsOfKind(input, group) {
191
+ const kinds = PROP_KINDS[group];
192
+ return input.visible.filter((d) => kinds.includes(d.kind));
193
+ }
194
+ /**
195
+ * A sky field of the map's tileset: from its CTerrain in the map's TerrainData.xml and that
196
+ * entry's parents there, the first that sets it; else the stock tileset's (data/tileset-sky.json)
197
+ * the chain ends on, or the map's tileset id's own stock entry, which the map may override.
198
+ */
199
+ function tilesetSkyField(map, field) {
200
+ const tag = SKY_TAGS.find(([, f]) => f === field)[0];
201
+ const local = new Map(xmlElements(map.terrainData, "CTerrain").map((t) => [t.attrs.id, t]));
202
+ const seen = new Set();
203
+ let id = map.terrain.tilesetId;
204
+ for (let entry = local.get(id); entry && !seen.has(id); entry = local.get(id)) {
205
+ seen.add(id);
206
+ const set = xmlElement(entry.body, tag)?.attrs.value;
207
+ if (set !== undefined)
208
+ return set;
209
+ if (!entry.attrs.parent)
210
+ break;
211
+ id = entry.attrs.parent;
212
+ }
213
+ return getTilesetSky(EMPTY_CATALOG, id)?.[field] ?? getTilesetSky(EMPTY_CATALOG, map.terrain.tilesetId)?.[field];
214
+ }
215
+ export function backdrop(input) {
216
+ const { grid, main, map } = input;
217
+ const hidesLowestLevel = tilesetSkyField(map, "hideLowestLevel") === "1";
218
+ const fogEnabled = tilesetSkyField(map, "fogEnabled");
219
+ const density = tilesetSkyField(map, "fogDensity");
220
+ let cells = 0;
221
+ let underWater = 0;
222
+ let underSky = 0;
223
+ let covered = 0;
224
+ for (let i = 0; i < grid.width * grid.height; i++) {
225
+ if (!grid.isPlayable[i] || grid.isRamp[i] || grid.level[i] >= main)
226
+ continue;
227
+ cells++;
228
+ const x = (i % grid.width) + 0.5;
229
+ const y = Math.floor(i / grid.width) + 0.5;
230
+ const water = map.waterAreas.some(({ rect: [x0, y0, x1, y1] }) => x >= x0 && x < x1 && y >= y0 && y < y1);
231
+ const sky = hidesLowestLevel && grid.level[i] === 0;
232
+ if (water)
233
+ underWater++;
234
+ if (sky)
235
+ underSky++;
236
+ if (water || sky)
237
+ covered++;
238
+ }
239
+ const fogDensity = fogEnabled === "0" ? 0 : density !== undefined && Number.isFinite(Number(density)) ? Number(density) : undefined;
240
+ return { cells, underWater, underSky, covered, hidesLowestLevel, fogDensity };
241
+ }
242
+ /** Whether a doodad type is a point light (an omni light doodad). */
243
+ export const isPointLight = (type) => /^LightOmni/.test(type);
244
+ export function lightingChanges(input) {
245
+ const calls = lightingCalls(input.map.mapScript);
246
+ const blends = calls.map((c) => c.blendSeconds).filter((b) => typeof b === "number");
247
+ return {
248
+ lights: [...new Set(calls.map((c) => c.light))],
249
+ changes: calls.length,
250
+ instant: blends.filter((b) => b === 0).length,
251
+ longestBlendSeconds: blends.length ? Math.max(...blends) : undefined,
252
+ pointLights: input.doodads.filter((d) => isPointLight(d.type)).length,
253
+ };
254
+ }
255
+ /**
256
+ * Every 4-neighbour step between two whole levels, with whether the dominant texture differs
257
+ * `back` cells behind the edge on each side. Split into crossings down into a pit (the low side
258
+ * below the main level), up onto a height (the high side above it) and the others. Edges in the
259
+ * map's outer two cells (three on the north and east) are left out, and so is a crossing whose
260
+ * sample cells fall off the map. The measures sample 2 cells back; the Antioch pack's lessons
261
+ * script lets its maintainer try others.
262
+ */
263
+ export function cliffCrossings(input, back = 2) {
264
+ const { grid, dominant, main } = input;
265
+ const { width: W, height: H } = grid;
266
+ const cross = { down: [0, 0], up: [0, 0], other: [0, 0] };
267
+ for (let y = 2; y < H - 3; y++) {
268
+ for (let x = 2; x < W - 3; x++) {
269
+ const i = y * W + x;
270
+ if (!grid.isPlayable[i] || grid.isRamp[i])
271
+ continue;
272
+ for (const [dx, dy] of [[1, 0], [0, 1]]) {
273
+ const j = (y + dy) * W + (x + dx);
274
+ if (grid.isRamp[j] || grid.level[j] === grid.level[i])
275
+ continue;
276
+ const [ax, ay] = [x - back * dx, y - back * dy];
277
+ const [bx, by] = [x + (1 + back) * dx, y + (1 + back) * dy];
278
+ if (ax < 0 || ay < 0 || bx >= W || by >= H)
279
+ continue;
280
+ const a = ay * W + ax;
281
+ const b = by * W + bx;
282
+ const lo = Math.min(grid.level[i], grid.level[j]);
283
+ const hi = Math.max(grid.level[i], grid.level[j]);
284
+ const k = lo < main ? "down" : hi > main ? "up" : "other";
285
+ cross[k][0]++;
286
+ if (dominant[a] !== dominant[b])
287
+ cross[k][1]++;
288
+ }
289
+ }
290
+ }
291
+ return cross;
292
+ }
293
+ /** Every measure `measureMap` gives, in the order a report lists them. */
294
+ export const MEASURES = [
295
+ { id: "topTextureShare.lowestLevel", description: "share of the lowest level's cells whose dominant texture is its top texture; none when the lowest level is the main level" },
296
+ { id: "topTextureShare.mainLevel", description: "share of the main level's cells whose dominant texture is its top texture" },
297
+ { id: "topTextureShare.highestLevel", description: "share of the highest level's cells whose dominant texture is its top texture; none when the highest level is the main level" },
298
+ { id: "cliffTextureChange.downIntoPit", description: "share of cliff crossings down into a pit (below the main level) whose dominant texture differs 2 cells back on each side" },
299
+ { id: "cliffTextureChange.upOntoHeight", description: "share of cliff crossings up onto a height (above the main level) whose dominant texture differs 2 cells back on each side" },
300
+ { id: "doodadDensity.lowestLevel", description: "the lowest level's share of the visible doodads over its share of the ground (1 = as dense as the map); none when the lowest level is the main level" },
301
+ { id: "doodadDensity.mainLevel", description: "the main level's share of the visible doodads over its share of the ground (1 = as dense as the map)" },
302
+ { id: "doodadDensity.highestLevel", description: "the highest level's share of the visible doodads over its share of the ground (1 = as dense as the map); none when the highest level is the main level" },
303
+ { id: "doodadDensity.perHundredCells", description: "visible doodads on playable ground per 100 playable, non-ramp cells" },
304
+ { id: "frameAreas.singleTextureShare", description: "share of frame-sized areas (18x12 cells) on the main level holding one texture, a texture counting from 0.5% of an area" },
305
+ { id: "blend.nearBorderShare", description: "share of blended cells (two or more textures each giving 10%) within 2 cells of a border between dominant textures" },
306
+ { id: "blend.width", description: "blended cells within 2 cells of a border, per cell side of border between dominant textures on playable ground: roughly the blend band's mean width in cells, from thin seams (near 0) to wide soft blends (at most about 5)" },
307
+ { id: "blend.singleTextureCellShare", description: "share of playable cells with only one texture giving 10% or more" },
308
+ { id: "yawSnapping.natural", description: "share of visible natural props (rocks, trees, foliage) turned to within a degree of a 45-degree step" },
309
+ { id: "yawSnapping.built", description: "share of visible built props (ruins and other structures) turned to within a degree of a 45-degree step" },
310
+ { id: "yawSnapping.decal", description: "share of visible decals turned to within a degree of a 45-degree step" },
311
+ { id: "backdrop.share", description: "share of the playable, non-ramp ground below the main level (the backdrop: pits, abyss floors, void)" },
312
+ { id: "backdrop.waterShare", description: "share of the backdrop under a water or lava area" },
313
+ { id: "backdrop.skyShare", description: "share of the backdrop on a hidden lowest level, showing the sky" },
314
+ { id: "backdrop.coveredShare", description: "share of the backdrop under water or lava or showing the sky" },
315
+ { id: "backdrop.fogDensity", description: "the map's tileset fog density, its own CTerrain's where it sets one; 0 with fog off" },
316
+ { id: "lighting.lightsSet", description: "distinct lights the map's triggers set (GameSetLighting)" },
317
+ { id: "lighting.changes", description: "GameSetLighting calls in the map's triggers" },
318
+ { id: "lighting.instantShare", description: "share of the triggers' lighting changes that cut at once (a blend time of 0)" },
319
+ { id: "lighting.longestBlendSeconds", description: "the longest blend time of a trigger's lighting change, in seconds" },
320
+ { id: "lighting.pointLightShare", description: "share of all doodads that are point lights (LightOmni)" },
321
+ { id: "lighting.pointLightsPerHundredCells", description: "point lights (LightOmni) per 100 playable, non-ramp cells" },
322
+ ];
323
+ const value = (v) => (v === null || v === undefined || !Number.isFinite(v) ? null : round(v));
324
+ /** Every lesson-neutral measure of one map. */
325
+ export function measureMap(map, catalog = EMPTY_CATALOG) {
326
+ const input = measureInput(map, catalog);
327
+ const { main } = input;
328
+ const lowest = input.levels[0];
329
+ const highest = input.levels.at(-1);
330
+ const top = new Map(topTextureByLevel(input).map((t) => [t.level, t.share]));
331
+ const cross = cliffCrossings(input);
332
+ const frames = frameAreaTexturing(input);
333
+ const blends = blendPlacement(input);
334
+ const back = backdrop(input);
335
+ const light = lightingChanges(input);
336
+ const changed = ([n, c]) => (n ? c / n : null);
337
+ return {
338
+ "topTextureShare.lowestLevel": lowest === main ? null : value(top.get(lowest)),
339
+ "topTextureShare.mainLevel": value(top.get(main)),
340
+ "topTextureShare.highestLevel": highest === main ? null : value(top.get(highest)),
341
+ "cliffTextureChange.downIntoPit": value(changed(cross.down)),
342
+ "cliffTextureChange.upOntoHeight": value(changed(cross.up)),
343
+ "doodadDensity.lowestLevel": lowest === main ? null : value(doodadDensityRatio(input, lowest)),
344
+ "doodadDensity.mainLevel": value(doodadDensityRatio(input, main)),
345
+ "doodadDensity.highestLevel": highest === main ? null : value(doodadDensityRatio(input, highest)),
346
+ "doodadDensity.perHundredCells": value((visibleOnPlayable(input).length / input.playable) * 100),
347
+ "frameAreas.singleTextureShare": value(frames.areas ? frames.singleTexture / frames.areas : null),
348
+ "blend.nearBorderShare": value(blends.blended ? blends.blendedNearBorder / blends.blended : null),
349
+ "blend.width": value(blends.borderEdges ? blends.blendedNearBorder / blends.borderEdges : null),
350
+ "blend.singleTextureCellShare": value(blends.singleTexture / blends.cells),
351
+ "yawSnapping.natural": value(snappedShare(propsOfKind(input, "natural"))),
352
+ "yawSnapping.built": value(snappedShare(propsOfKind(input, "built"))),
353
+ "yawSnapping.decal": value(snappedShare(propsOfKind(input, "decal"))),
354
+ "backdrop.share": value(back.cells / input.playable),
355
+ "backdrop.waterShare": value(back.cells ? back.underWater / back.cells : null),
356
+ "backdrop.skyShare": value(back.cells ? back.underSky / back.cells : null),
357
+ "backdrop.coveredShare": value(back.cells ? back.covered / back.cells : null),
358
+ "backdrop.fogDensity": value(back.fogDensity),
359
+ "lighting.lightsSet": light.lights.length,
360
+ "lighting.changes": light.changes,
361
+ "lighting.instantShare": value(light.changes ? light.instant / light.changes : null),
362
+ "lighting.longestBlendSeconds": value(light.longestBlendSeconds),
363
+ "lighting.pointLightShare": value(input.doodads.length ? light.pointLights / input.doodads.length : null),
364
+ "lighting.pointLightsPerHundredCells": value((light.pointLights / input.playable) * 100),
365
+ };
366
+ }
@@ -0,0 +1,58 @@
1
+ import type { MachineConfig } from "../host/machine-config.js";
2
+ import { type ExemplarProvenance } from "../plugins/plugin-api.js";
3
+ import { type Workspace } from "../plugins/workspace.js";
4
+ /** Where a new pack goes in the Workspace, by default. */
5
+ export declare const DEFAULT_STYLE_PACK_FOLDER = "style-pack";
6
+ /** What a pack's Exemplar Maps folder never commits: tours, their frames, cited frames and minimaps. */
7
+ export declare const STYLE_PACK_IGNORES: readonly ["*/captures/", "*/frames/", "*/evidence/", "*/minimap.png"];
8
+ export type ScaffoldStylePackOptions = {
9
+ /** The pack's folder, relative to the Workspace root; `style-pack` by default. */
10
+ readonly folder?: string;
11
+ /** The Plugin's name; `style-<campaign id>` by default. */
12
+ readonly name?: string;
13
+ /** Replace the Style Pack the Workspace config already names. Refused without it when it names one. */
14
+ readonly replace?: boolean;
15
+ };
16
+ export type ScaffoldedStylePack = {
17
+ readonly name: string;
18
+ /** Absolute. */
19
+ readonly folder: string;
20
+ /** As the Workspace config's stylePack now names it. */
21
+ readonly source: string;
22
+ /** The files written, relative to the pack's folder. */
23
+ readonly files: readonly string[];
24
+ /** The Style Pack the config named before, as it named it, when this replaced one. */
25
+ readonly replaced?: string;
26
+ };
27
+ /**
28
+ * Makes a Style Pack Plugin in `folder` of the Workspace at `root`, and names it as the Workspace
29
+ * config's stylePack: its manifest with the style-pack role and knowledge entries, an empty
30
+ * Exemplar Maps list, LESSONS.md and candidate-lessons.md with their headings and the lesson
31
+ * format, a GUIDE.md stub and the .gitignore for what captures write. Refused, before anything is
32
+ * written, when the folder is outside the Workspace, exists and isn't empty, or when the config
33
+ * names a Style Pack already and `replace` isn't set.
34
+ */
35
+ export declare function scaffoldStylePack(root: string, options?: ScaffoldStylePackOptions): Promise<ScaffoldedStylePack>;
36
+ export type AddExemplarMapOptions = {
37
+ readonly id: string;
38
+ /** The source map, inside the Workspace's Exemplar Map folder (or absolute). */
39
+ readonly map: string;
40
+ readonly provenance: ExemplarProvenance;
41
+ readonly note?: string;
42
+ readonly machine?: Pick<MachineConfig, "file" | "exemplarMaps">;
43
+ };
44
+ export type AddedExemplarMap = {
45
+ readonly id: string;
46
+ readonly map: string;
47
+ readonly provenance: ExemplarProvenance;
48
+ /** The Exemplar Maps list written, absolute. */
49
+ readonly file: string;
50
+ /** The source map found, absolute. */
51
+ readonly source: string;
52
+ };
53
+ /**
54
+ * Records an Exemplar Map in the active Style Pack's Exemplar Maps list: its id, its source map
55
+ * and its provenance. Refused, before anything is written, when the Workspace's Style Pack isn't
56
+ * a local folder, the id is taken, or the source map isn't there.
57
+ */
58
+ export declare function addExemplarMap(workspace: Workspace, { id, map, provenance, note, machine }: AddExemplarMapOptions): Promise<AddedExemplarMap>;