Add content-manifest script for generated game content docs.
Derives harvest, equip, potion, and mob tables from shared definitions; output markdown is gitignored. Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -10,3 +10,4 @@ client/frameworkv3/js/framework.js
10
10
client/public/framework.js
11
11
.env
12
12
.env.local
13
docs/content-manifest.generated.md
@@ -10,3 +10,4 @@ client/frameworkv3/js/framework.js10
client/public/framework.js10
client/public/framework.js11
.env11
.env12
.env.local12
.env.local13
docs/content-manifest.generated.md@@ -9,7 +9,8 @@
9
9
"start": "node --experimental-sqlite server/src/index.js",
10
10
"test": "node --experimental-sqlite --test server/tests/**/*.test.js client/tests/**/*.test.js",
11
11
"test:smoke": "node --experimental-sqlite --test server/tests/smoke-boot.test.js",
12
"build:client": "node client/scripts/build-framework.mjs"
12
"build:client": "node client/scripts/build-framework.mjs",
13
"content-manifest": "node scripts/content-manifest.mjs"
13
14
},
14
15
"dependencies": {
15
16
"ws": "^8.18.3"
@@ -9,7 +9,8 @@9
"start": "node --experimental-sqlite server/src/index.js",9
"start": "node --experimental-sqlite server/src/index.js",10
"test": "node --experimental-sqlite --test server/tests/**/*.test.js client/tests/**/*.test.js",10
"test": "node --experimental-sqlite --test server/tests/**/*.test.js client/tests/**/*.test.js",11
"test:smoke": "node --experimental-sqlite --test server/tests/smoke-boot.test.js",11
"test:smoke": "node --experimental-sqlite --test server/tests/smoke-boot.test.js",12
"build:client": "node client/scripts/build-framework.mjs"12
"build:client": "node client/scripts/build-framework.mjs",13
"content-manifest": "node scripts/content-manifest.mjs"13
},14
},14
"dependencies": {15
"dependencies": {15
"ws": "^8.18.3"16
"ws": "^8.18.3"@@ -0,0 +1,567 @@
1
/**
2
* Generate docs/content-manifest.generated.md from shared definitions.
3
* Output is gitignored — run: npm run content-manifest
4
*/
5
import { mkdirSync, writeFileSync } from "node:fs";
6
import { dirname, join } from "node:path";
7
import { fileURLToPath } from "node:url";
8
9
import
10
{
11
MATERIAL_TIER_ORDER,
12
WOOD_TIER_ORDER,
13
CLOTH_TIER_ORDER,
14
LEATHER_TIER_ORDER,
15
GEM_TIER_ORDER,
16
ORE_BEARING_MATERIALS,
17
GatherMaterialId,
18
MaterialTier,
19
ClothTier,
20
LeatherTier,
21
MATERIAL_DISPLAY_NAME,
22
CLOTH_DISPLAY_NAME,
23
LEATHER_DISPLAY_NAME,
24
tierMinSkillLevel,
25
tierMineSkillLevel,
26
associatedBarTier,
27
isGemstoneMaterial,
28
metalTierForCloth
29
} from "../shared/definitions/materialTiers.js";
30
import
31
{
32
toolTierMeetsResource,
33
toolTierMeetsGemstone
34
} from "../shared/definitions/gathering.js";
35
import { HERB_DEFINITIONS, HERB_ORDER, herbGatherSkillLevel } from "../shared/definitions/herbs.js";
36
import { CRAFT_RECIPES } from "../shared/crafting/stationRecipes.js";
37
import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js";
38
import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js";
39
import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js";
40
import { itemDefinition } from "../shared/definitions/items.js";
41
import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js";
42
import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js";
43
import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js";
44
import { fishingRodItemIdForWood } from "../shared/definitions/fishItems.js";
45
import { leatherMaterialItemId } from "../shared/definitions/leatherItems.js";
46
import { SkillId } from "../shared/definitions/skills.js";
47
48
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
49
const OUT = join(ROOT, "docs/content-manifest.generated.md");
50
51
const EQUIP_LEVELS = MATERIAL_TIER_ORDER.map((tier) => tierMinSkillLevel(tier));
52
53
function esc (text)
54
{
55
return String(text ?? "").replace(/\|/g, "\\|").replace(/\n/g, " ");
56
}
57
58
function mdTable (headers, rows)
59
{
60
const head = `| ${headers.map(esc).join(" | ")} |`;
61
const sep = `| ${headers.map(() => "---").join(" | ")} |`;
62
const body = rows.map((row) => `| ${row.map(esc).join(" | ")} |`).join("\n");
63
return `${head}\n${sep}\n${body}`;
64
}
65
66
function materialLabel (materialId)
67
{
68
const name = MATERIAL_DISPLAY_NAME[materialId] ?? materialId;
69
if (materialId === GatherMaterialId.coal)
70
{ return "Coal"; }
71
if (materialId === GatherMaterialId.salt)
72
{ return "Rock salt"; }
73
if (isGemstoneMaterial(materialId))
74
{ return name; }
75
return `${name} ore`;
76
}
77
78
/** Lowest metal tool tier that can gather this resource (ores / wood). */
79
function minMetalToolTier (resourceTier, { gem = false } = {})
80
{
81
const gate = associatedBarTier(resourceTier);
82
for (const metal of MATERIAL_TIER_ORDER)
83
{
84
const ok = gem
85
? toolTierMeetsGemstone(metal, gate)
86
: toolTierMeetsResource(metal, gate);
87
if (ok)
88
{ return metal; }
89
}
90
return MaterialTier.bronze;
91
}
92
93
function toolLabel (metalTier, kind)
94
{
95
const name = MATERIAL_DISPLAY_NAME[metalTier] ?? metalTier;
96
return `${name} ${kind}`;
97
}
98
99
function clothGatherRows ()
100
{
101
const rows = [];
102
for (const cloth of CLOTH_TIER_ORDER)
103
{
104
const name = CLOTH_DISPLAY_NAME[cloth] ?? cloth;
105
const metal = metalTierForCloth(cloth);
106
if (cloth === ClothTier.cotton)
107
{
108
rows.push([name, "1 (Herbalism)", "None (pick cotton plant)", "Plant node"]);
109
continue;
110
}
111
if (cloth === ClothTier.linen)
112
{
113
rows.push([
114
name,
115
String(tierMinSkillLevel(metal)),
116
`${toolLabel(metal, "plant clippers")} or better`,
117
"Flax plant (clippers)"
118
]);
119
continue;
120
}
121
if (cloth === ClothTier.silk)
122
{
123
rows.push([
124
name,
125
String(tierMinSkillLevel(metal)),
126
`${toolLabel(metal, "plant clippers")} or better`,
127
"Silk cocoon (clippers)"
128
]);
129
continue;
130
}
131
if (cloth === ClothTier.wool)
132
{
133
rows.push([
134
name,
135
String(tierMinSkillLevel(metal)),
136
`${toolLabel(metal, "shears")} or better`,
137
"Shear sheep"
138
]);
139
continue;
140
}
141
if (cloth === ClothTier.cashmere)
142
{
143
rows.push([
144
name,
145
String(tierMinSkillLevel(metal)),
146
`${toolLabel(metal, "shears")} or better`,
147
"Shear goat"
148
]);
149
continue;
150
}
151
if (cloth === ClothTier.fairySilk)
152
{
153
rows.push([name, "—", "—", "Fairy death drop (~70%)"]);
154
continue;
155
}
156
if (cloth === ClothTier.dragonweave)
157
{
158
rows.push([name, "—", "—", "No gather path yet"]);
159
continue;
160
}
161
rows.push([name, "—", "—", "Unknown"]);
162
}
163
return rows;
164
}
165
166
function leatherSourceRows ()
167
{
168
const materialIds = new Set(
169
LEATHER_TIER_ORDER.map((tier) => leatherMaterialItemId(tier)).filter((id) => id != null)
170
);
171
const craftByOutputId = new Map();
172
for (const recipe of CRAFT_RECIPES)
173
{
174
const outId = recipe.output?.itemId;
175
if (outId == null || !materialIds.has(outId))
176
{ continue; }
177
const inputs = (recipe.inputs ?? []).map((row) =>
178
{
179
const name = itemDefinition(row.itemId)?.displayName ?? String(row.itemId);
180
return `${row.quantity}× ${name}`;
181
}).join(" + ");
182
let extra = "";
183
if (recipe.consumePotionKey)
184
{
185
const potion = ALCHEMY_POTION_DEFINITIONS[recipe.consumePotionKey];
186
extra = ` + 1 fill of ${potion?.displayName ?? recipe.consumePotionKey}`;
187
}
188
const skill = recipe.skillId
189
? `${recipe.skillId} ${recipe.minSkillLevel ?? "?"}`
190
: "";
191
craftByOutputId.set(outId, `Craft: ${inputs}${extra}${skill ? ` (${skill})` : ""}`);
192
}
193
194
const dropSources = softLeatherDropSources();
195
return LEATHER_TIER_ORDER.map((tier) =>
196
{
197
const name = LEATHER_DISPLAY_NAME[tier] ?? tier;
198
if (tier === LeatherTier.softLeather)
199
{
200
return [name, dropSources || "Mob drops", "—"];
201
}
202
const craft = craftByOutputId.get(leatherMaterialItemId(tier));
203
if (craft)
204
{ return [name, craft, "—"]; }
205
return [name, "No craft/drop path in definitions yet", "—"];
206
});
207
}
208
209
function softLeatherDropSources ()
210
{
211
const parts = [];
212
for (const mob of Object.values(MOB_DEFINITIONS))
213
{
214
for (const drop of mob.drops ?? [])
215
{
216
const def = itemDefinition(drop.itemId);
217
if (def?.tier === LeatherTier.softLeather || def?.key === "leather" || def?.key === "soft-leather")
218
{
219
const pct = Math.round((drop.chance ?? 0) * 100);
220
parts.push(`${mob.displayName} (${pct}%)`);
221
}
222
}
223
}
224
return parts.length ? `Drop: ${parts.join(", ")}` : "";
225
}
226
227
function formatDrop (drop)
228
{
229
const name = itemDefinition(drop.itemId)?.displayName ?? `item#${drop.itemId}`;
230
const pct = Math.round((drop.chance ?? 0) * 100);
231
let qty = "";
232
if (drop.quantityMin != null && drop.quantityMax != null)
233
{ qty = `${drop.quantityMin}-${drop.quantityMax} `; }
234
else if (drop.quantity != null && drop.quantity !== 1)
235
{ qty = `${drop.quantity} `; }
236
return `${pct}% ${qty}${name}`;
237
}
238
239
function potionRecipeCell (potion)
240
{
241
const ingredients = (potion.ingredients ?? []).map((row) =>
242
{
243
if (row.potionKey)
244
{ return `${row.quantity}× ${ALCHEMY_POTION_DEFINITIONS[row.potionKey]?.displayName ?? row.potionKey}`; }
245
return `${row.quantity}× ${alchemyItemLabel({ key: row.key, itemId: row.itemId })}`;
246
}).join(", ");
247
const steps = (potion.steps ?? []).map((step) => formatAlchemyStep(step)).join(" → ");
248
return `Ingredients: ${ingredients}. Steps: ${steps}`;
249
}
250
251
function equipLevelHeaders ()
252
{
253
return ["Kind", ...EQUIP_LEVELS.map((level) => `Lv ${level}`)];
254
}
255
256
function metalTierCells (labelForTier)
257
{
258
return MATERIAL_TIER_ORDER.map((tier) => labelForTier(tier));
259
}
260
261
function woodTierCells (labelForTier)
262
{
263
return WOOD_TIER_ORDER.map((tier) => labelForTier(tier));
264
}
265
266
function clothTierCells (labelForTier)
267
{
268
return CLOTH_TIER_ORDER.map((tier) => labelForTier(tier));
269
}
270
271
function leatherTierCells (labelForTier)
272
{
273
return LEATHER_TIER_ORDER.map((tier) => labelForTier(tier));
274
}
275
276
function buildMarkdown ()
277
{
278
const lines = [];
279
const generatedAt = new Date().toISOString();
280
lines.push("# Content manifest");
281
lines.push("");
282
lines.push(`_Generated ${generatedAt} by \`scripts/content-manifest.mjs\`. Do not edit by hand._`);
283
lines.push("");
284
lines.push("Skill gates follow shared rules: gather ≈ ceil(equip/2); tool may be **one metal tier below** the resource (gemstones require **equal or better** pickaxe).");
285
lines.push("");
286
287
// --- Ores ---
288
lines.push("## Ores");
289
lines.push("");
290
{
291
const rows = [];
292
for (const material of ORE_BEARING_MATERIALS)
293
{
294
if (material === GatherMaterialId.bronze || material === GatherMaterialId.steel)
295
{ continue; }
296
if (isGemstoneMaterial(material))
297
{ continue; }
298
const gate = associatedBarTier(material);
299
const mineLv = tierMineSkillLevel(material);
300
const gem = false;
301
const minTool = minMetalToolTier(gate, { gem });
302
rows.push([
303
materialLabel(material),
304
String(mineLv),
305
`${toolLabel(minTool, "pickaxe")} or better`,
306
`Gate tier: ${MATERIAL_DISPLAY_NAME[gate] ?? gate}`
307
]);
308
}
309
lines.push(mdTable(["Ore", "Mining level", "Min pickaxe", "Notes"], rows));
310
}
311
lines.push("");
312
313
// --- Wood ---
314
lines.push("## Wood");
315
lines.push("");
316
{
317
const rows = WOOD_TIER_ORDER.map((wood) =>
318
{
319
const name = MATERIAL_DISPLAY_NAME[wood] ?? wood;
320
const chopLv = tierMineSkillLevel(wood);
321
const minTool = minMetalToolTier(wood, { gem: false });
322
return [
323
name,
324
String(chopLv),
325
`${toolLabel(minTool, "axe")} or better`
326
];
327
});
328
lines.push(mdTable(["Wood", "Woodcutting level", "Min axe"], rows));
329
}
330
lines.push("");
331
332
// --- Cloth / wool fibre ---
333
lines.push("## Cloth fibre (wool & plants)");
334
lines.push("");
335
lines.push("Shears / clippers must be equippable (Herbalism = tier equip gate). Plants without clippers have no skill gate.");
336
lines.push("");
337
lines.push(mdTable(
338
["Fibre", "Level", "Tool", "How"],
339
clothGatherRows()
340
));
341
lines.push("");
342
343
// --- Herbs ---
344
lines.push("## Herbs");
345
lines.push("");
346
{
347
const rows = HERB_ORDER.map((herbId) =>
348
{
349
const herb = HERB_DEFINITIONS[herbId];
350
return [
351
herb.displayName,
352
String(herb.tier),
353
String(herbGatherSkillLevel(herb.tier)),
354
"Plant clippers (any equippable tier)"
355
];
356
});
357
lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows));
358
}
359
lines.push("");
360
361
// --- Gemstones ---
362
lines.push("## Gemstones");
363
lines.push("");
364
{
365
const rows = GEM_TIER_ORDER.map((gem) =>
366
{
367
const name = MATERIAL_DISPLAY_NAME[gem] ?? gem;
368
const mineLv = tierMineSkillLevel(gem);
369
const minTool = minMetalToolTier(gem, { gem: true });
370
return [
371
name,
372
String(mineLv),
373
`${toolLabel(minTool, "pickaxe")} or better (equal tier+)`
374
];
375
});
376
lines.push(mdTable(["Gemstone", "Mining level", "Min pickaxe"], rows));
377
}
378
lines.push("");
379
380
// --- Leather ---
381
lines.push("## Leather");
382
lines.push("");
383
lines.push(mdTable(
384
["Leather", "How obtained", "Tool"],
385
leatherSourceRows()
386
));
387
lines.push("");
388
389
// --- Tool equip table ---
390
lines.push("## Tool equip levels");
391
lines.push("");
392
lines.push(`Columns are equip skill levels (${SkillId.woodcutting} / ${SkillId.mining} / ${SkillId.herbalism} / ${SkillId.fishing} as appropriate).`);
393
lines.push("");
394
{
395
const rows = [
396
["Axe", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],
397
["Pickaxe", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],
398
["Plant clippers", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],
399
["Shears", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],
400
[
401
"Fishing rod",
402
...woodTierCells((w) => (fishingRodItemIdForWood(w)
403
? MATERIAL_DISPLAY_NAME[w]
404
: "—"))
405
]
406
];
407
lines.push(mdTable(equipLevelHeaders(), rows));
408
}
409
lines.push("");
410
411
// --- Metal armour ---
412
lines.push("## Metal armour equip levels");
413
lines.push("");
414
lines.push("Defence skill. Full helms require equip level **+1** vs other pieces of the same tier.");
415
lines.push("");
416
{
417
const rows = ARMOUR_CRAFT_PIECES.map((piece) =>
418
{
419
const cells = MATERIAL_TIER_ORDER.map((tier) =>
420
{
421
const base = tierMinSkillLevel(tier);
422
const level = piece.fullHelm ? base + 1 : base;
423
return `${MATERIAL_DISPLAY_NAME[tier]} (Lv ${level})`;
424
});
425
return [piece.label, ...cells];
426
});
427
lines.push(mdTable(equipLevelHeaders(), rows));
428
}
429
lines.push("");
430
431
// --- Leather armour ---
432
lines.push("## Leather armour equip levels");
433
lines.push("");
434
lines.push("Defence skill.");
435
lines.push("");
436
{
437
const rows = LEATHER_ARMOUR_PIECES.map((piece) =>
438
[piece.label, ...leatherTierCells((t) => LEATHER_DISPLAY_NAME[t])]
439
);
440
lines.push(mdTable(
441
["Kind", ...LEATHER_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)],
442
rows
443
));
444
}
445
lines.push("");
446
447
// --- Cloth armour ---
448
lines.push("## Cloth armour equip levels");
449
lines.push("");
450
lines.push("Defence skill. Pieces: shirt, shorts, trousers, skirt, sweater.");
451
lines.push("");
452
{
453
const pieces = ["shirt", "shorts", "trousers", "skirt", "sweater"];
454
const rows = pieces.map((piece) =>
455
[piece, ...clothTierCells((t) => CLOTH_DISPLAY_NAME[t])]
456
);
457
lines.push(mdTable(
458
["Kind", ...CLOTH_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)],
459
rows
460
));
461
}
462
lines.push("");
463
464
// --- Wizard ---
465
lines.push("## Wizard armour equip levels");
466
lines.push("");
467
lines.push("Magic skill. Cloth-tier gated.");
468
lines.push("");
469
{
470
const rows = WIZARD_PIECES.map((piece) =>
471
[piece.label, ...clothTierCells((t) => CLOTH_DISPLAY_NAME[t])]
472
);
473
lines.push(mdTable(
474
["Kind", ...CLOTH_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)],
475
rows
476
));
477
}
478
lines.push("");
479
480
// --- Melee ---
481
lines.push("## Melee weapons equip levels");
482
lines.push("");
483
{
484
const rows = [
485
["Sword (swordfighting)", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],
486
["War axe (axefighting)", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],
487
["Quarterstaff (clubfighting)", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])]
488
];
489
lines.push(mdTable(equipLevelHeaders(), rows));
490
}
491
lines.push("");
492
493
// --- Ranged ---
494
lines.push("## Ranged weapons equip levels");
495
lines.push("");
496
lines.push("Archery skill. Bows are wood-tier; arrows are metal-tier.");
497
lines.push("");
498
{
499
const rows = [
500
["Bow", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])],
501
["Arrow", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])]
502
];
503
lines.push(mdTable(equipLevelHeaders(), rows));
504
}
505
lines.push("");
506
507
// --- Magic ---
508
lines.push("## Magic weapons equip levels");
509
lines.push("");
510
lines.push("Magic skill. Staves are wood-tier (with matching gem).");
511
lines.push("");
512
{
513
const rows = [
514
["Staff", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])]
515
];
516
lines.push(mdTable(equipLevelHeaders(), rows));
517
}
518
lines.push("");
519
520
// --- Potions ---
521
lines.push("## Potions");
522
lines.push("");
523
{
524
const potions = Object.values(ALCHEMY_POTION_DEFINITIONS)
525
.slice()
526
.sort((a, b) => (a.minAlchemyLevel | 0) - (b.minAlchemyLevel | 0)
527
|| String(a.displayName).localeCompare(String(b.displayName)));
528
const rows = potions.map((p) => [
529
p.displayName,
530
String(p.minAlchemyLevel | 0 || 1),
531
potionRecipeCell(p),
532
p.description ?? ""
533
]);
534
lines.push(mdTable(["Potion", "Alchemy level", "Recipe", "Description"], rows));
535
}
536
lines.push("");
537
538
// --- Mobs ---
539
lines.push("## Mobs");
540
lines.push("");
541
{
542
const rows = Object.values(MOB_DEFINITIONS).map((mob) =>
543
{
544
const level = defaultSpawnerConfig(`manifest-${mob.mobTypeId}`, mob.mobTypeId).level;
545
const drops = (mob.drops ?? []).map(formatDrop).join(", ") || "—";
546
return [
547
mob.displayName || mob.mobTypeId,
548
mob.mobTypeId,
549
String(level),
550
mob.aggressive ? "yes" : "no",
551
drops
552
];
553
});
554
lines.push(mdTable(
555
["Name", "Id", "Default level", "Aggressive", "Drops"],
556
rows
557
));
558
}
559
lines.push("");
560
561
return `${lines.join("\n")}\n`;
562
}
563
564
mkdirSync(dirname(OUT), { recursive: true });
565
const markdown = buildMarkdown();
566
writeFileSync(OUT, markdown, "utf8");
567
console.log(`Wrote ${OUT} (${markdown.length} bytes)`);
@@ -0,0 +1,567 @@1
/**2
* Generate docs/content-manifest.generated.md from shared definitions.3
* Output is gitignored — run: npm run content-manifest4
*/5
import { mkdirSync, writeFileSync } from "node:fs";6
import { dirname, join } from "node:path";7
import { fileURLToPath } from "node:url";8
9
import10
{11
MATERIAL_TIER_ORDER,12
WOOD_TIER_ORDER,13
CLOTH_TIER_ORDER,14
LEATHER_TIER_ORDER,15
GEM_TIER_ORDER,16
ORE_BEARING_MATERIALS,17
GatherMaterialId,18
MaterialTier,19
ClothTier,20
LeatherTier,21
MATERIAL_DISPLAY_NAME,22
CLOTH_DISPLAY_NAME,23
LEATHER_DISPLAY_NAME,24
tierMinSkillLevel,25
tierMineSkillLevel,26
associatedBarTier,27
isGemstoneMaterial,28
metalTierForCloth29
} from "../shared/definitions/materialTiers.js";30
import31
{32
toolTierMeetsResource,33
toolTierMeetsGemstone34
} from "../shared/definitions/gathering.js";35
import { HERB_DEFINITIONS, HERB_ORDER, herbGatherSkillLevel } from "../shared/definitions/herbs.js";36
import { CRAFT_RECIPES } from "../shared/crafting/stationRecipes.js";37
import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js";38
import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js";39
import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js";40
import { itemDefinition } from "../shared/definitions/items.js";41
import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js";42
import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js";43
import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js";44
import { fishingRodItemIdForWood } from "../shared/definitions/fishItems.js";45
import { leatherMaterialItemId } from "../shared/definitions/leatherItems.js";46
import { SkillId } from "../shared/definitions/skills.js";47
48
const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");49
const OUT = join(ROOT, "docs/content-manifest.generated.md");50
51
const EQUIP_LEVELS = MATERIAL_TIER_ORDER.map((tier) => tierMinSkillLevel(tier));52
53
function esc (text)54
{55
return String(text ?? "").replace(/\|/g, "\\|").replace(/\n/g, " ");56
}57
58
function mdTable (headers, rows)59
{60
const head = `| ${headers.map(esc).join(" | ")} |`;61
const sep = `| ${headers.map(() => "---").join(" | ")} |`;62
const body = rows.map((row) => `| ${row.map(esc).join(" | ")} |`).join("\n");63
return `${head}\n${sep}\n${body}`;64
}65
66
function materialLabel (materialId)67
{68
const name = MATERIAL_DISPLAY_NAME[materialId] ?? materialId;69
if (materialId === GatherMaterialId.coal)70
{ return "Coal"; }71
if (materialId === GatherMaterialId.salt)72
{ return "Rock salt"; }73
if (isGemstoneMaterial(materialId))74
{ return name; }75
return `${name} ore`;76
}77
78
/** Lowest metal tool tier that can gather this resource (ores / wood). */79
function minMetalToolTier (resourceTier, { gem = false } = {})80
{81
const gate = associatedBarTier(resourceTier);82
for (const metal of MATERIAL_TIER_ORDER)83
{84
const ok = gem85
? toolTierMeetsGemstone(metal, gate)86
: toolTierMeetsResource(metal, gate);87
if (ok)88
{ return metal; }89
}90
return MaterialTier.bronze;91
}92
93
function toolLabel (metalTier, kind)94
{95
const name = MATERIAL_DISPLAY_NAME[metalTier] ?? metalTier;96
return `${name} ${kind}`;97
}98
99
function clothGatherRows ()100
{101
const rows = [];102
for (const cloth of CLOTH_TIER_ORDER)103
{104
const name = CLOTH_DISPLAY_NAME[cloth] ?? cloth;105
const metal = metalTierForCloth(cloth);106
if (cloth === ClothTier.cotton)107
{108
rows.push([name, "1 (Herbalism)", "None (pick cotton plant)", "Plant node"]);109
continue;110
}111
if (cloth === ClothTier.linen)112
{113
rows.push([114
name,115
String(tierMinSkillLevel(metal)),116
`${toolLabel(metal, "plant clippers")} or better`,117
"Flax plant (clippers)"118
]);119
continue;120
}121
if (cloth === ClothTier.silk)122
{123
rows.push([124
name,125
String(tierMinSkillLevel(metal)),126
`${toolLabel(metal, "plant clippers")} or better`,127
"Silk cocoon (clippers)"128
]);129
continue;130
}131
if (cloth === ClothTier.wool)132
{133
rows.push([134
name,135
String(tierMinSkillLevel(metal)),136
`${toolLabel(metal, "shears")} or better`,137
"Shear sheep"138
]);139
continue;140
}141
if (cloth === ClothTier.cashmere)142
{143
rows.push([144
name,145
String(tierMinSkillLevel(metal)),146
`${toolLabel(metal, "shears")} or better`,147
"Shear goat"148
]);149
continue;150
}151
if (cloth === ClothTier.fairySilk)152
{153
rows.push([name, "—", "—", "Fairy death drop (~70%)"]);154
continue;155
}156
if (cloth === ClothTier.dragonweave)157
{158
rows.push([name, "—", "—", "No gather path yet"]);159
continue;160
}161
rows.push([name, "—", "—", "Unknown"]);162
}163
return rows;164
}165
166
function leatherSourceRows ()167
{168
const materialIds = new Set(169
LEATHER_TIER_ORDER.map((tier) => leatherMaterialItemId(tier)).filter((id) => id != null)170
);171
const craftByOutputId = new Map();172
for (const recipe of CRAFT_RECIPES)173
{174
const outId = recipe.output?.itemId;175
if (outId == null || !materialIds.has(outId))176
{ continue; }177
const inputs = (recipe.inputs ?? []).map((row) =>178
{179
const name = itemDefinition(row.itemId)?.displayName ?? String(row.itemId);180
return `${row.quantity}× ${name}`;181
}).join(" + ");182
let extra = "";183
if (recipe.consumePotionKey)184
{185
const potion = ALCHEMY_POTION_DEFINITIONS[recipe.consumePotionKey];186
extra = ` + 1 fill of ${potion?.displayName ?? recipe.consumePotionKey}`;187
}188
const skill = recipe.skillId189
? `${recipe.skillId} ${recipe.minSkillLevel ?? "?"}`190
: "";191
craftByOutputId.set(outId, `Craft: ${inputs}${extra}${skill ? ` (${skill})` : ""}`);192
}193
194
const dropSources = softLeatherDropSources();195
return LEATHER_TIER_ORDER.map((tier) =>196
{197
const name = LEATHER_DISPLAY_NAME[tier] ?? tier;198
if (tier === LeatherTier.softLeather)199
{200
return [name, dropSources || "Mob drops", "—"];201
}202
const craft = craftByOutputId.get(leatherMaterialItemId(tier));203
if (craft)204
{ return [name, craft, "—"]; }205
return [name, "No craft/drop path in definitions yet", "—"];206
});207
}208
209
function softLeatherDropSources ()210
{211
const parts = [];212
for (const mob of Object.values(MOB_DEFINITIONS))213
{214
for (const drop of mob.drops ?? [])215
{216
const def = itemDefinition(drop.itemId);217
if (def?.tier === LeatherTier.softLeather || def?.key === "leather" || def?.key === "soft-leather")218
{219
const pct = Math.round((drop.chance ?? 0) * 100);220
parts.push(`${mob.displayName} (${pct}%)`);221
}222
}223
}224
return parts.length ? `Drop: ${parts.join(", ")}` : "";225
}226
227
function formatDrop (drop)228
{229
const name = itemDefinition(drop.itemId)?.displayName ?? `item#${drop.itemId}`;230
const pct = Math.round((drop.chance ?? 0) * 100);231
let qty = "";232
if (drop.quantityMin != null && drop.quantityMax != null)233
{ qty = `${drop.quantityMin}-${drop.quantityMax} `; }234
else if (drop.quantity != null && drop.quantity !== 1)235
{ qty = `${drop.quantity} `; }236
return `${pct}% ${qty}${name}`;237
}238
239
function potionRecipeCell (potion)240
{241
const ingredients = (potion.ingredients ?? []).map((row) =>242
{243
if (row.potionKey)244
{ return `${row.quantity}× ${ALCHEMY_POTION_DEFINITIONS[row.potionKey]?.displayName ?? row.potionKey}`; }245
return `${row.quantity}× ${alchemyItemLabel({ key: row.key, itemId: row.itemId })}`;246
}).join(", ");247
const steps = (potion.steps ?? []).map((step) => formatAlchemyStep(step)).join(" → ");248
return `Ingredients: ${ingredients}. Steps: ${steps}`;249
}250
251
function equipLevelHeaders ()252
{253
return ["Kind", ...EQUIP_LEVELS.map((level) => `Lv ${level}`)];254
}255
256
function metalTierCells (labelForTier)257
{258
return MATERIAL_TIER_ORDER.map((tier) => labelForTier(tier));259
}260
261
function woodTierCells (labelForTier)262
{263
return WOOD_TIER_ORDER.map((tier) => labelForTier(tier));264
}265
266
function clothTierCells (labelForTier)267
{268
return CLOTH_TIER_ORDER.map((tier) => labelForTier(tier));269
}270
271
function leatherTierCells (labelForTier)272
{273
return LEATHER_TIER_ORDER.map((tier) => labelForTier(tier));274
}275
276
function buildMarkdown ()277
{278
const lines = [];279
const generatedAt = new Date().toISOString();280
lines.push("# Content manifest");281
lines.push("");282
lines.push(`_Generated ${generatedAt} by \`scripts/content-manifest.mjs\`. Do not edit by hand._`);283
lines.push("");284
lines.push("Skill gates follow shared rules: gather ≈ ceil(equip/2); tool may be **one metal tier below** the resource (gemstones require **equal or better** pickaxe).");285
lines.push("");286
287
// --- Ores ---288
lines.push("## Ores");289
lines.push("");290
{291
const rows = [];292
for (const material of ORE_BEARING_MATERIALS)293
{294
if (material === GatherMaterialId.bronze || material === GatherMaterialId.steel)295
{ continue; }296
if (isGemstoneMaterial(material))297
{ continue; }298
const gate = associatedBarTier(material);299
const mineLv = tierMineSkillLevel(material);300
const gem = false;301
const minTool = minMetalToolTier(gate, { gem });302
rows.push([303
materialLabel(material),304
String(mineLv),305
`${toolLabel(minTool, "pickaxe")} or better`,306
`Gate tier: ${MATERIAL_DISPLAY_NAME[gate] ?? gate}`307
]);308
}309
lines.push(mdTable(["Ore", "Mining level", "Min pickaxe", "Notes"], rows));310
}311
lines.push("");312
313
// --- Wood ---314
lines.push("## Wood");315
lines.push("");316
{317
const rows = WOOD_TIER_ORDER.map((wood) =>318
{319
const name = MATERIAL_DISPLAY_NAME[wood] ?? wood;320
const chopLv = tierMineSkillLevel(wood);321
const minTool = minMetalToolTier(wood, { gem: false });322
return [323
name,324
String(chopLv),325
`${toolLabel(minTool, "axe")} or better`326
];327
});328
lines.push(mdTable(["Wood", "Woodcutting level", "Min axe"], rows));329
}330
lines.push("");331
332
// --- Cloth / wool fibre ---333
lines.push("## Cloth fibre (wool & plants)");334
lines.push("");335
lines.push("Shears / clippers must be equippable (Herbalism = tier equip gate). Plants without clippers have no skill gate.");336
lines.push("");337
lines.push(mdTable(338
["Fibre", "Level", "Tool", "How"],339
clothGatherRows()340
));341
lines.push("");342
343
// --- Herbs ---344
lines.push("## Herbs");345
lines.push("");346
{347
const rows = HERB_ORDER.map((herbId) =>348
{349
const herb = HERB_DEFINITIONS[herbId];350
return [351
herb.displayName,352
String(herb.tier),353
String(herbGatherSkillLevel(herb.tier)),354
"Plant clippers (any equippable tier)"355
];356
});357
lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows));358
}359
lines.push("");360
361
// --- Gemstones ---362
lines.push("## Gemstones");363
lines.push("");364
{365
const rows = GEM_TIER_ORDER.map((gem) =>366
{367
const name = MATERIAL_DISPLAY_NAME[gem] ?? gem;368
const mineLv = tierMineSkillLevel(gem);369
const minTool = minMetalToolTier(gem, { gem: true });370
return [371
name,372
String(mineLv),373
`${toolLabel(minTool, "pickaxe")} or better (equal tier+)`374
];375
});376
lines.push(mdTable(["Gemstone", "Mining level", "Min pickaxe"], rows));377
}378
lines.push("");379
380
// --- Leather ---381
lines.push("## Leather");382
lines.push("");383
lines.push(mdTable(384
["Leather", "How obtained", "Tool"],385
leatherSourceRows()386
));387
lines.push("");388
389
// --- Tool equip table ---390
lines.push("## Tool equip levels");391
lines.push("");392
lines.push(`Columns are equip skill levels (${SkillId.woodcutting} / ${SkillId.mining} / ${SkillId.herbalism} / ${SkillId.fishing} as appropriate).`);393
lines.push("");394
{395
const rows = [396
["Axe", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],397
["Pickaxe", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],398
["Plant clippers", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],399
["Shears", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],400
[401
"Fishing rod",402
...woodTierCells((w) => (fishingRodItemIdForWood(w)403
? MATERIAL_DISPLAY_NAME[w]404
: "—"))405
]406
];407
lines.push(mdTable(equipLevelHeaders(), rows));408
}409
lines.push("");410
411
// --- Metal armour ---412
lines.push("## Metal armour equip levels");413
lines.push("");414
lines.push("Defence skill. Full helms require equip level **+1** vs other pieces of the same tier.");415
lines.push("");416
{417
const rows = ARMOUR_CRAFT_PIECES.map((piece) =>418
{419
const cells = MATERIAL_TIER_ORDER.map((tier) =>420
{421
const base = tierMinSkillLevel(tier);422
const level = piece.fullHelm ? base + 1 : base;423
return `${MATERIAL_DISPLAY_NAME[tier]} (Lv ${level})`;424
});425
return [piece.label, ...cells];426
});427
lines.push(mdTable(equipLevelHeaders(), rows));428
}429
lines.push("");430
431
// --- Leather armour ---432
lines.push("## Leather armour equip levels");433
lines.push("");434
lines.push("Defence skill.");435
lines.push("");436
{437
const rows = LEATHER_ARMOUR_PIECES.map((piece) =>438
[piece.label, ...leatherTierCells((t) => LEATHER_DISPLAY_NAME[t])]439
);440
lines.push(mdTable(441
["Kind", ...LEATHER_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)],442
rows443
));444
}445
lines.push("");446
447
// --- Cloth armour ---448
lines.push("## Cloth armour equip levels");449
lines.push("");450
lines.push("Defence skill. Pieces: shirt, shorts, trousers, skirt, sweater.");451
lines.push("");452
{453
const pieces = ["shirt", "shorts", "trousers", "skirt", "sweater"];454
const rows = pieces.map((piece) =>455
[piece, ...clothTierCells((t) => CLOTH_DISPLAY_NAME[t])]456
);457
lines.push(mdTable(458
["Kind", ...CLOTH_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)],459
rows460
));461
}462
lines.push("");463
464
// --- Wizard ---465
lines.push("## Wizard armour equip levels");466
lines.push("");467
lines.push("Magic skill. Cloth-tier gated.");468
lines.push("");469
{470
const rows = WIZARD_PIECES.map((piece) =>471
[piece.label, ...clothTierCells((t) => CLOTH_DISPLAY_NAME[t])]472
);473
lines.push(mdTable(474
["Kind", ...CLOTH_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)],475
rows476
));477
}478
lines.push("");479
480
// --- Melee ---481
lines.push("## Melee weapons equip levels");482
lines.push("");483
{484
const rows = [485
["Sword (swordfighting)", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],486
["War axe (axefighting)", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])],487
["Quarterstaff (clubfighting)", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])]488
];489
lines.push(mdTable(equipLevelHeaders(), rows));490
}491
lines.push("");492
493
// --- Ranged ---494
lines.push("## Ranged weapons equip levels");495
lines.push("");496
lines.push("Archery skill. Bows are wood-tier; arrows are metal-tier.");497
lines.push("");498
{499
const rows = [500
["Bow", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])],501
["Arrow", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])]502
];503
lines.push(mdTable(equipLevelHeaders(), rows));504
}505
lines.push("");506
507
// --- Magic ---508
lines.push("## Magic weapons equip levels");509
lines.push("");510
lines.push("Magic skill. Staves are wood-tier (with matching gem).");511
lines.push("");512
{513
const rows = [514
["Staff", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])]515
];516
lines.push(mdTable(equipLevelHeaders(), rows));517
}518
lines.push("");519
520
// --- Potions ---521
lines.push("## Potions");522
lines.push("");523
{524
const potions = Object.values(ALCHEMY_POTION_DEFINITIONS)525
.slice()526
.sort((a, b) => (a.minAlchemyLevel | 0) - (b.minAlchemyLevel | 0)527
|| String(a.displayName).localeCompare(String(b.displayName)));528
const rows = potions.map((p) => [529
p.displayName,530
String(p.minAlchemyLevel | 0 || 1),531
potionRecipeCell(p),532
p.description ?? ""533
]);534
lines.push(mdTable(["Potion", "Alchemy level", "Recipe", "Description"], rows));535
}536
lines.push("");537
538
// --- Mobs ---539
lines.push("## Mobs");540
lines.push("");541
{542
const rows = Object.values(MOB_DEFINITIONS).map((mob) =>543
{544
const level = defaultSpawnerConfig(`manifest-${mob.mobTypeId}`, mob.mobTypeId).level;545
const drops = (mob.drops ?? []).map(formatDrop).join(", ") || "—";546
return [547
mob.displayName || mob.mobTypeId,548
mob.mobTypeId,549
String(level),550
mob.aggressive ? "yes" : "no",551
drops552
];553
});554
lines.push(mdTable(555
["Name", "Id", "Default level", "Aggressive", "Drops"],556
rows557
));558
}559
lines.push("");560
561
return `${lines.join("\n")}\n`;562
}563
564
mkdirSync(dirname(OUT), { recursive: true });565
const markdown = buildMarkdown();566
writeFileSync(OUT, markdown, "utf8");567
console.log(`Wrote ${OUT} (${markdown.length} bytes)`);