/** * Generate docs/content-manifest.generated.md from shared definitions. * Output is gitignored — run: npm run content-manifest */ import { mkdirSync, writeFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; import { MATERIAL_TIER_ORDER, WOOD_TIER_ORDER, CLOTH_TIER_ORDER, LEATHER_TIER_ORDER, GEM_TIER_ORDER, ORE_BEARING_MATERIALS, GatherMaterialId, MaterialTier, ClothTier, LeatherTier, MATERIAL_DISPLAY_NAME, CLOTH_DISPLAY_NAME, LEATHER_DISPLAY_NAME, tierMinSkillLevel, tierMineSkillLevel, associatedBarTier, isGemstoneMaterial, metalTierForCloth, metalTierForHerbTier } from "../shared/definitions/materialTiers.js"; import { toolTierMeetsResource, toolTierMeetsGemstone } from "../shared/definitions/gathering.js"; import { HERB_DEFINITIONS, HERB_ORDER, herbGatherSkillLevel } from "../shared/definitions/herbs.js"; import { CRAFT_RECIPES } from "../shared/crafting/stationRecipes.js"; import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js"; import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js"; import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js"; import { ITEM_DEFINITIONS, itemDefinition } from "../shared/definitions/items.js"; import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js"; import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js"; import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js"; import { fishingRodItemIdForWood } from "../shared/definitions/fishItems.js"; import { leatherMaterialItemId } from "../shared/definitions/leatherItems.js"; import { SkillId } from "../shared/definitions/skills.js"; const ROOT = join(dirname(fileURLToPath(import.meta.url)), ".."); const OUT = join(ROOT, "docs/content-manifest.generated.md"); const EQUIP_LEVELS = MATERIAL_TIER_ORDER.map((tier) => tierMinSkillLevel(tier)); function esc (text) { return String(text ?? "").replace(/\|/g, "\\|").replace(/\n/g, " "); } function mdTable (headers, rows) { const head = `| ${headers.map(esc).join(" | ")} |`; const sep = `| ${headers.map(() => "---").join(" | ")} |`; const body = rows.map((row) => `| ${row.map(esc).join(" | ")} |`).join("\n"); return `${head}\n${sep}\n${body}`; } function materialLabel (materialId) { const name = MATERIAL_DISPLAY_NAME[materialId] ?? materialId; if (materialId === GatherMaterialId.coal) { return "Coal"; } if (materialId === GatherMaterialId.salt) { return "Rock salt"; } if (isGemstoneMaterial(materialId)) { return name; } return `${name} ore`; } /** Lowest metal tool tier that can gather this resource (ores / wood). */ function minMetalToolTier (resourceTier, { gem = false } = {}) { const gate = associatedBarTier(resourceTier); for (const metal of MATERIAL_TIER_ORDER) { const ok = gem ? toolTierMeetsGemstone(metal, gate) : toolTierMeetsResource(metal, gate); if (ok) { return metal; } } return MaterialTier.bronze; } function toolLabel (metalTier, kind) { const name = MATERIAL_DISPLAY_NAME[metalTier] ?? metalTier; return `${name} ${kind}`; } function clothGatherRows () { const rows = []; for (const cloth of CLOTH_TIER_ORDER) { const name = CLOTH_DISPLAY_NAME[cloth] ?? cloth; const metal = metalTierForCloth(cloth); if (cloth === ClothTier.cotton) { rows.push([name, "1 (Herbalism)", "None (pick cotton plant)", "Plant node"]); continue; } if (cloth === ClothTier.linen) { rows.push([ name, String(tierMinSkillLevel(metal)), `${toolLabel(metal, "plant clippers")} or better`, "Flax plant (clippers)" ]); continue; } if (cloth === ClothTier.silk) { rows.push([ name, String(tierMinSkillLevel(metal)), `${toolLabel(metal, "plant clippers")} or better`, "Silk cocoon (clippers)" ]); continue; } if (cloth === ClothTier.wool) { rows.push([ name, String(tierMinSkillLevel(metal)), `${toolLabel(metal, "shears")} or better`, "Shear sheep" ]); continue; } if (cloth === ClothTier.cashmere) { rows.push([ name, String(tierMinSkillLevel(metal)), `${toolLabel(metal, "shears")} or better`, "Shear goat" ]); continue; } if (cloth === ClothTier.fairySilk) { rows.push([name, "—", "—", "Fairy death drop (~70%)"]); continue; } if (cloth === ClothTier.dragonweave) { rows.push([name, "—", "—", "No gather path yet"]); continue; } rows.push([name, "—", "—", "Unknown"]); } return rows; } function leatherSourceRows () { const materialIds = new Set( LEATHER_TIER_ORDER.map((tier) => leatherMaterialItemId(tier)).filter((id) => id != null) ); const craftByOutputId = new Map(); for (const recipe of CRAFT_RECIPES) { const outId = recipe.output?.itemId; if (outId == null || !materialIds.has(outId)) { continue; } const inputs = (recipe.inputs ?? []).map((row) => { const name = itemDefinition(row.itemId)?.displayName ?? String(row.itemId); return `${row.quantity}× ${name}`; }).join(" + "); let extra = ""; if (recipe.consumePotionKey) { const potion = ALCHEMY_POTION_DEFINITIONS[recipe.consumePotionKey]; extra = ` + 1 fill of ${potion?.displayName ?? recipe.consumePotionKey}`; } const skill = recipe.skillId ? `${recipe.skillId} ${recipe.minSkillLevel ?? "?"}` : ""; craftByOutputId.set(outId, `Craft: ${inputs}${extra}${skill ? ` (${skill})` : ""}`); } const dropSources = softLeatherDropSources(); return LEATHER_TIER_ORDER.map((tier) => { const name = LEATHER_DISPLAY_NAME[tier] ?? tier; if (tier === LeatherTier.softLeather) { return [name, dropSources || "Mob drops", "—"]; } const craft = craftByOutputId.get(leatherMaterialItemId(tier)); if (craft) { return [name, craft, "—"]; } return [name, "No craft/drop path in definitions yet", "—"]; }); } function softLeatherDropSources () { const parts = []; for (const mob of Object.values(MOB_DEFINITIONS)) { for (const drop of mob.drops ?? []) { const def = itemDefinition(drop.itemId); if (def?.tier === LeatherTier.softLeather || def?.key === "leather" || def?.key === "soft-leather") { const pct = Math.round((drop.chance ?? 0) * 100); parts.push(`${mob.displayName} (${pct}%)`); } } } return parts.length ? `Drop: ${parts.join(", ")}` : ""; } function formatDrop (drop) { const name = itemDefinition(drop.itemId)?.displayName ?? `item#${drop.itemId}`; const pct = Math.round((drop.chance ?? 0) * 100); let qty = ""; if (drop.quantityMin != null && drop.quantityMax != null) { qty = `${drop.quantityMin}-${drop.quantityMax} `; } else if (drop.quantity != null && drop.quantity !== 1) { qty = `${drop.quantity} `; } return `${pct}% ${qty}${name}`; } function potionRecipeCell (potion) { const ingredients = (potion.ingredients ?? []).map((row) => { if (row.potionKey) { return `${row.quantity}× ${ALCHEMY_POTION_DEFINITIONS[row.potionKey]?.displayName ?? row.potionKey}`; } return `${row.quantity}× ${alchemyItemLabel({ key: row.key, itemId: row.itemId })}`; }).join(", "); const steps = (potion.steps ?? []).map((step) => formatAlchemyStep(step)).join(" → "); return `Ingredients: ${ingredients}. Steps: ${steps}`; } function equipLevelHeaders () { return ["Kind", ...EQUIP_LEVELS.map((level) => `Lv ${level}`)]; } function metalTierCells (labelForTier) { return MATERIAL_TIER_ORDER.map((tier) => labelForTier(tier)); } function woodTierCells (labelForTier) { return WOOD_TIER_ORDER.map((tier) => labelForTier(tier)); } function clothTierCells (labelForTier) { return CLOTH_TIER_ORDER.map((tier) => labelForTier(tier)); } function leatherTierCells (labelForTier) { return LEATHER_TIER_ORDER.map((tier) => labelForTier(tier)); } function buildMarkdown () { const lines = []; const generatedAt = new Date().toISOString(); lines.push("# Content manifest"); lines.push(""); lines.push(`_Generated ${generatedAt} by \`scripts/content-manifest.mjs\`. Do not edit by hand._`); lines.push(""); 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)."); lines.push(""); // --- Ores --- lines.push("## Ores"); lines.push(""); { const rows = []; for (const material of ORE_BEARING_MATERIALS) { if (material === GatherMaterialId.bronze || material === GatherMaterialId.steel) { continue; } if (isGemstoneMaterial(material)) { continue; } const gate = associatedBarTier(material); const mineLv = tierMineSkillLevel(material); const gem = false; const minTool = minMetalToolTier(gate, { gem }); rows.push([ materialLabel(material), String(mineLv), `${toolLabel(minTool, "pickaxe")} or better`, `Gate tier: ${MATERIAL_DISPLAY_NAME[gate] ?? gate}` ]); } lines.push(mdTable(["Ore", "Mining level", "Min pickaxe", "Notes"], rows)); } lines.push(""); // --- Wood --- lines.push("## Wood"); lines.push(""); { const rows = WOOD_TIER_ORDER.map((wood) => { const name = MATERIAL_DISPLAY_NAME[wood] ?? wood; const chopLv = tierMineSkillLevel(wood); const minTool = minMetalToolTier(wood, { gem: false }); return [ name, String(chopLv), `${toolLabel(minTool, "axe")} or better` ]; }); lines.push(mdTable(["Wood", "Woodcutting level", "Min axe"], rows)); } lines.push(""); // --- Cloth / wool fibre --- lines.push("## Cloth fibre (wool & plants)"); lines.push(""); lines.push("Shears / clippers must be equippable (Herbalism = tier equip gate). Plants without clippers have no skill gate."); lines.push(""); lines.push(mdTable( ["Fibre", "Level", "Tool", "How"], clothGatherRows() )); lines.push(""); // --- Herbs --- lines.push("## Herbs"); lines.push(""); { const rows = HERB_ORDER.map((herbId) => { const herb = HERB_DEFINITIONS[herbId]; const metal = metalTierForHerbTier(herb.tier); return [ herb.displayName, String(herb.tier), String(herbGatherSkillLevel(herb.tier)), `${toolLabel(metal, "plant clippers")} or better` ]; }); lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows)); } lines.push(""); // --- Gemstones --- lines.push("## Gemstones"); lines.push(""); { const rows = GEM_TIER_ORDER.map((gem) => { const name = MATERIAL_DISPLAY_NAME[gem] ?? gem; const mineLv = tierMineSkillLevel(gem); const minTool = minMetalToolTier(gem, { gem: true }); return [ name, String(mineLv), `${toolLabel(minTool, "pickaxe")} or better (equal tier+)` ]; }); lines.push(mdTable(["Gemstone", "Mining level", "Min pickaxe"], rows)); } lines.push(""); // --- Leather --- lines.push("## Leather"); lines.push(""); lines.push(mdTable( ["Leather", "How obtained", "Tool"], leatherSourceRows() )); lines.push(""); // --- Tool equip table --- lines.push("## Tool equip levels"); lines.push(""); lines.push(`Columns are equip skill levels (${SkillId.woodcutting} / ${SkillId.mining} / ${SkillId.herbalism} / ${SkillId.fishing} as appropriate).`); lines.push(""); { const rows = [ ["Axe", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])], ["Pickaxe", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])], ["Plant clippers", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])], ["Shears", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])], [ "Fishing rod", ...woodTierCells((w) => (fishingRodItemIdForWood(w) ? MATERIAL_DISPLAY_NAME[w] : "—")) ] ]; lines.push(mdTable(equipLevelHeaders(), rows)); } lines.push(""); // --- Metal armour --- lines.push("## Metal armour equip levels"); lines.push(""); lines.push("Defence skill. Full helms require equip level **+1** vs other pieces of the same tier."); lines.push(""); { const rows = ARMOUR_CRAFT_PIECES.map((piece) => { const cells = MATERIAL_TIER_ORDER.map((tier) => { const base = tierMinSkillLevel(tier); const level = piece.fullHelm ? base + 1 : base; return `${MATERIAL_DISPLAY_NAME[tier]} (Lv ${level})`; }); return [piece.label, ...cells]; }); lines.push(mdTable(equipLevelHeaders(), rows)); } lines.push(""); // --- Leather armour --- lines.push("## Leather armour equip levels"); lines.push(""); lines.push("Defence skill."); lines.push(""); { const rows = LEATHER_ARMOUR_PIECES.map((piece) => [piece.label, ...leatherTierCells((t) => LEATHER_DISPLAY_NAME[t])] ); lines.push(mdTable( ["Kind", ...LEATHER_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)], rows )); } lines.push(""); // --- Cloth armour --- lines.push("## Cloth armour equip levels"); lines.push(""); lines.push("Defence skill. Pieces: shirt, shorts, trousers, skirt, sweater."); lines.push(""); { const pieces = ["shirt", "shorts", "trousers", "skirt", "sweater"]; const rows = pieces.map((piece) => [piece, ...clothTierCells((t) => CLOTH_DISPLAY_NAME[t])] ); lines.push(mdTable( ["Kind", ...CLOTH_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)], rows )); } lines.push(""); // --- Wizard --- lines.push("## Wizard armour equip levels"); lines.push(""); lines.push("Magic skill. Cloth-tier gated."); lines.push(""); { const rows = WIZARD_PIECES.map((piece) => [piece.label, ...clothTierCells((t) => CLOTH_DISPLAY_NAME[t])] ); lines.push(mdTable( ["Kind", ...CLOTH_TIER_ORDER.map((t) => `Lv ${tierMinSkillLevel(t)}`)], rows )); } lines.push(""); // --- Melee --- lines.push("## Melee weapons equip levels"); lines.push(""); { const rows = [ ["Sword (swordfighting)", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])], ["War axe (axefighting)", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])], ["Quarterstaff (clubfighting)", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])] ]; lines.push(mdTable(equipLevelHeaders(), rows)); } lines.push(""); // --- Ranged --- lines.push("## Ranged weapons equip levels"); lines.push(""); lines.push("Archery skill. Bows are wood-tier; arrows are metal-tier."); lines.push(""); { const rows = [ ["Bow", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])], ["Arrow", ...metalTierCells((t) => MATERIAL_DISPLAY_NAME[t])] ]; lines.push(mdTable(equipLevelHeaders(), rows)); } lines.push(""); // --- Magic --- lines.push("## Magic weapons equip levels"); lines.push(""); lines.push("Magic skill. Staves are wood-tier (with matching gem)."); lines.push(""); { const rows = [ ["Staff", ...woodTierCells((t) => MATERIAL_DISPLAY_NAME[t])] ]; lines.push(mdTable(equipLevelHeaders(), rows)); } lines.push(""); // --- Potions --- lines.push("## Potions"); lines.push(""); { const potions = Object.values(ALCHEMY_POTION_DEFINITIONS) .slice() .sort((a, b) => (a.minAlchemyLevel | 0) - (b.minAlchemyLevel | 0) || String(a.displayName).localeCompare(String(b.displayName))); const rows = potions.map((p) => [ p.displayName, String(p.minAlchemyLevel | 0 || 1), potionRecipeCell(p), p.description ?? "" ]); lines.push(mdTable(["Potion", "Alchemy level", "Recipe", "Description"], rows)); } lines.push(""); // --- Mobs --- lines.push("## Mobs"); lines.push(""); { const rows = Object.values(MOB_DEFINITIONS).map((mob) => { const level = defaultSpawnerConfig(`manifest-${mob.mobTypeId}`, mob.mobTypeId).level; const drops = (mob.drops ?? []).map(formatDrop).join(", ") || "—"; return [ mob.displayName || mob.mobTypeId, mob.mobTypeId, String(level), mob.aggressive ? "yes" : "no", drops ]; }); lines.push(mdTable( ["Name", "Id", "Default level", "Aggressive", "Drops"], rows )); } lines.push(""); // --- All items --- lines.push("## All items"); lines.push(""); { const rows = Object.values(ITEM_DEFINITIONS) .filter((def) => def?.itemId != null) .slice() .sort((a, b) => String(a.displayName ?? "").localeCompare(String(b.displayName ?? "")) || ((a.itemId | 0) - (b.itemId | 0))) .map((def) => [ def.displayName ?? String(def.itemId), String(def.itemId), def.key ?? "—", def.description ?? "—" ]); lines.push(mdTable(["Name", "Id", "Key", "Description"], rows)); } lines.push(""); return `${lines.join("\n")}\n`; } mkdirSync(dirname(OUT), { recursive: true }); const markdown = buildMarkdown(); writeFileSync(OUT, markdown, "utf8"); console.log(`Wrote ${OUT} (${markdown.length} bytes)`);