diff --git a/.gitignore b/.gitignore index 6222b845..9ae34385 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ batch/dist/ .pnpm-store .playwright-mcp/ /artifacts/achievement-portraits/ +/artifacts/achievement-scenes/ diff --git a/docs/achievements.md b/docs/achievements.md index ef7fcc23..a329ebea 100644 --- a/docs/achievements.md +++ b/docs/achievements.md @@ -7,7 +7,7 @@ or a claim that achievements have been enabled on the hosted service. ## Hook contract -- `achievementDefinitions()` returns `{ revision: 4, achievements }`. Each definition +- `achievementDefinitions()` returns `{ revision: 5, achievements }`. Each definition has string `id`, `name`, and `description` fields and an optional strict `icon`: `{ type: "asset", key: string }` or `{ type: "text", text: string }`. Asset keys match `^[a-z0-9][a-z0-9-]{0,63}$`; text matches `^[A-Za-z0-9]{1,4}$`. No URLs, @@ -44,7 +44,7 @@ player order after removing Automa players; they are not raw engine player numbe Automa never receives a result. Dropped humans retain their human seat index and return `{ seat, earned: [] }`, with no outcome, rather than shifting later seats. -## Revision 4 catalog (36 IDs) +## Revision 5 catalog (36 IDs) IDs follow BGS's `^[a-z0-9][a-z0-9-]{0,63}$` validator: lowercase letters, ASCII digits, and hyphens, at most 64 characters. All 36 IDs are unique. The @@ -54,13 +54,15 @@ and were never published. Revision 2 added 18 faction asset references and four raster score assets: `achievement-score-150` and `achievement-score-200`. That revision-2-to-3 artwork change preserved all 36 IDs and earned predicates. Revision 4 raises both federation thresholds to four and renames the general -federation ID, as detailed below. There are still 22 icon-bearing -definitions referencing 20 unique assets; the remaining 14 definitions have no icon. +federation ID, as detailed below. Revision 5 adds original scene artwork to the +remaining 14 definitions: all 36 now reference 34 assets. The 22 previously illustrated +rows retain their exact 20 keys and public image bytes. IDs, descriptions, and +evaluation are unchanged from revision 4. **Deployment order:** the platform icon contract (platform commit `fca050c9509c1dec3afd8d4631cc57245f834f29`, platform PR [578](https://codeberg.org/boardgamers/boardgamers/pulls/578)) must be deployed -before activating this revision-4 manifest. Older strict validators reject `icon`. +before activating an icon-bearing manifest. Older strict validators reject `icon`. No production assets or achievement activation are implied by this source change. ### Faction victories (18) diff --git a/engine/achievements.spec.ts b/engine/achievements.spec.ts index f59714a2..7451e844 100644 --- a/engine/achievements.spec.ts +++ b/engine/achievements.spec.ts @@ -54,10 +54,10 @@ function solo(difficulty = "automa"): Record { } describe("BGS achievement hooks", () => { - it("exports a complete, unique, isolated revision-4 catalog", () => { + it("exports a complete, unique, isolated revision-5 catalog", () => { const manifest = achievementDefinitions(); const ids = manifest.achievements.map((definition) => definition.id); - expect(manifest.revision).to.equal(4); + expect(manifest.revision).to.equal(5); expect(ids).to.include("federation-form-4"); expect(ids).not.to.include("federation-form-3"); expect(ids).to.include("faction-ivits-growing-federation"); @@ -72,14 +72,14 @@ describe("BGS achievement hooks", () => { expect(achievementDefinitions().achievements[0].name).not.to.equal("mutated"); }); - it("references 18 faction assets and two shared score assets without changing IDs", () => { + it("references all 34 assets, preserving 18 faction and two shared score keys", () => { const definitions = achievementDefinitions().achievements; const assets = definitions.filter((definition) => definition.icon?.type === "asset"); const texts = definitions.filter((definition) => definition.icon?.type === "text"); - expect(assets).to.have.length(22); + expect(assets).to.have.length(36); expect(texts).to.have.length(0); const keys = assets.map((definition) => (definition.icon.type === "asset" ? definition.icon.key : "")); - expect(new Set(keys).size).to.equal(20); + expect(new Set(keys).size).to.equal(34); for (const faction of Faction.values(Expansion.All)) { expect(definitions.find((definition) => definition.id === `win-faction-${faction}`).icon).to.deep.equal({ type: "asset", diff --git a/engine/package.json b/engine/package.json index a500b399..c002bb3b 100644 --- a/engine/package.json +++ b/engine/package.json @@ -1,6 +1,6 @@ { "name": "@gaia-project/engine", - "version": "4.17.9", + "version": "4.17.10", "description": "Javascript engine for project gaia", "main": "dist/index.js", "types": "index.ts", diff --git a/engine/src/achievements.ts b/engine/src/achievements.ts index 4325ef88..21920de0 100644 --- a/engine/src/achievements.ts +++ b/engine/src/achievements.ts @@ -50,6 +50,7 @@ export function achievementDefinitions(): AchievementManifest { const name = mode === "base" ? "Base Game" : "Lost Fleet"; definitions.push({ id: `win-mode-${mode}`, + icon: { type: "asset", key: `achievement-win-mode-${mode}` }, name: `${name} Victory`, description: `Win a ${name} game, including shared first place.`, }); @@ -65,6 +66,7 @@ export function achievementDefinitions(): AchievementManifest { for (const difficulty of automaDifficulties) { definitions.push({ id: `win-automa-${difficulty}`, + icon: { type: "asset", key: `achievement-win-automa-${difficulty}` }, name: `Defeat ${displayName(difficulty)}`, description: `Win against Automa at exactly ${difficulty} difficulty. A tied score counts as a human win.`, }); @@ -72,46 +74,53 @@ export function achievementDefinitions(): AchievementManifest { definitions.push( { id: "build-all-standard", + icon: { type: "asset", key: "achievement-build-all-standard" }, name: "Full Deployment", description: "Finish with all 18 standard building pieces simultaneously deployed: 8 mines, 4 trading stations, 3 research labs, the institute and both academies. Excludes Lost Planet, artifacts, Gaiaformers and space stations. No win required.", }, { id: "federation-form-4", + icon: { type: "asset", key: "achievement-federation-form-4" }, name: "Federation Builder", description: "Complete at least four federation formations in one game (extensions of the growing federation for Ivits). Token rewards and rescores do not count. No win required.", }, { id: "explore-all-types-base", + icon: { type: "asset", key: "achievement-explore-all-types-base" }, name: "Every World: Base Game", description: "Finish a base game with main-owned colonies on all seven ordinary planet types, Gaia and the Lost Planet. Gaiaformers and Lantids shared mines do not count. No win required.", }, { id: "explore-all-types-lost-fleet", + icon: { type: "asset", key: "achievement-explore-all-types-lost-fleet" }, name: "Every World: Lost Fleet", description: "Finish a Lost Fleet game with main-owned colonies on all seven ordinary types, Gaia, Lost Planet, Asteroid and Protoplanet. Artifacts, Gaiaformers and Lantids shared mines do not count. No win required.", }, { id: "faction-ivits-growing-federation", + icon: { type: "asset", key: "achievement-faction-ivits-growing-federation" }, name: "Growing Federation", description: "As Ivits, complete at least four formation milestones of your growing federation in one game. No win required.", }, { id: "faction-lantids-shared-civilization", + icon: { type: "asset", key: "achievement-faction-lantids-shared-civilization" }, name: "Shared Civilization", description: "As Lantids, finish with at least six additional mines on opponents' colonies. No win required.", }, { id: "faction-bescods-balanced-research", + icon: { type: "asset", key: "achievement-faction-bescods-balanced-research" }, name: "Balanced Research", description: "As Bescods, finish at level 3 or higher on all six research tracks. No win required.", } ); - return { revision: 4, achievements: definitions }; + return { revision: 5, achievements: definitions }; } /** Evaluate authoritative completed state only; never advance play or recompute final scoring. */ diff --git a/package.json b/package.json index 47f2eed6..373b4799 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,9 @@ "test": "vitest run", "test:locales": "node scripts/check-locales.mjs viewer/src/localization && node --test scripts/localization.test.mjs", "generate:achievement-portraits": "node scripts/generate-achievement-portraits.mjs", - "test:achievement-portraits": "node --test scripts/achievement-portraits.test.mjs" + "test:achievement-portraits": "node --test scripts/achievement-portraits.test.mjs", + "generate:achievement-scenes": "node scripts/generate-achievement-scenes.mjs", + "test:achievement-scenes": "node --test scripts/achievement-scenes.test.mjs" }, "devDependencies": { "husky": "^5.0.9", diff --git a/scripts/achievement-scenes.test.mjs b/scripts/achievement-scenes.test.mjs new file mode 100644 index 00000000..8053edb6 --- /dev/null +++ b/scripts/achievement-scenes.test.mjs @@ -0,0 +1,142 @@ +import assert from "node:assert/strict"; +import { mkdtemp, readFile, readdir, rm } from "node:fs/promises"; +import { createRequire } from "node:module"; +import os from "node:os"; +import path from "node:path"; +import test from "node:test"; +import sharp from "sharp"; +import { ROOT, generateScenes, scenes, sha256, svgFor } from "./generate-achievement-scenes.mjs"; + +const require = createRequire(import.meta.url); +// GAIA_ART_PACK_ROOT points at the unpacked EXACT npm artifact for the release gate. +const engineRoot = process.env.GAIA_ART_PACK_ROOT || path.join(ROOT, "engine"); +const hooks = require(path.join(engineRoot, "dist/wrapper.js")); +const fixtures = path.join(ROOT, "scripts/assets/achievement-scenes"); +const json = async (name) => JSON.parse(await readFile(path.join(fixtures, name), "utf8")); +const preservedSources = await json("preserved-sources.json"); +async function checkSources() { + for (const [file, hash] of Object.entries(preservedSources)) + assert.equal(sha256(await readFile(path.join(ROOT, file))), hash, file); +} + +test("complete protocol asset references, 36 unchanged definitions, 22 preserved rows and unchanged evaluator", async () => { + const baseline = await json("baseline-manifest.json"); + const actual = hooks.achievementDefinitions(); + assert.equal(actual.revision, 5); + assert.equal(actual.achievements.length, 36); + assert.equal(new Set(actual.achievements.map((a) => a.id)).size, 36); + assert.deepEqual( + actual.achievements.map(({ icon, ...rest }) => rest), + baseline.achievements.map(({ icon, ...rest }) => rest) + ); + const preserved = baseline.achievements.filter((a) => a.icon); + assert.equal(preserved.length, 22); + for (const row of preserved) + assert.deepEqual( + actual.achievements.find((a) => a.id === row.id), + row + ); + const pins = await json("preserved-assets.json"); + assert.equal(pins.length, 20); + assert.deepEqual(new Set(pins.map((a) => a.key)), new Set(preserved.map((a) => a.icon.key))); + const generated = scenes().map((a) => `achievement-${a.id}`); + assert.equal(generated.length, 14); + assert.equal(new Set(generated).size, 14); + const allKeys = new Set([...generated, ...pins.map((a) => a.key)]); + assert.equal(allKeys.size, 34); + for (const row of actual.achievements) { + assert.deepEqual(Object.keys(row.icon).sort(), ["key", "type"]); + assert.equal(row.icon.type, "asset"); + assert.match(row.icon.key, /^[a-z0-9][a-z0-9-]{0,63}$/); + assert.ok(allKeys.has(row.icon.key)); + } + assert.deepEqual( + new Set(baseline.achievements.filter((a) => !a.icon).map((a) => a.id)), + new Set(scenes().map((a) => a.id)) + ); + const source = await readFile(path.join(engineRoot, "src/achievements.ts"), "utf8"); + assert.equal( + sha256(source.slice(source.indexOf("/** Evaluate authoritative"))), + (await readFile(path.join(fixtures, "baseline-evaluator.sha256"), "utf8")).trim() + ); + assert.equal(require(path.join(engineRoot, "package.json")).version, "4.17.10"); + // Real completed-game fixture exercises hooks in the packed artifact, not fabricated production data. + const finished = JSON.parse(await readFile(path.join(ROOT, "engine/fixtures/Beta-2.json"), "utf8")); + assert.ok(hooks.achievements(finished).length > 0); + for (const seat of hooks.achievements(finished)) + for (const id of seat.earned) assert.ok(actual.achievements.some((a) => a.id === id)); + await checkSources(); +}); + +test("exact depicted counts, sets and difficulty mapping; no victory marks on non-winning feats", () => { + const items = scenes(); + const item = (id) => items.find((a) => a.id === id); + const count = (id, fragment) => (svgFor(item(id)).match(new RegExp(fragment, "g")) || []).length; + for (const [kind, n] of Object.entries({ mine: 8, trade: 4, lab: 3, institute: 1, academy: 2 })) + assert.equal(count("build-all-standard", `data-building="${kind}"`), n); + assert.equal(count("federation-form-4", 'data-formation="true"'), 4); + assert.equal(count("faction-ivits-growing-federation", 'data-growing-federation="true"'), 1); + assert.equal(item("faction-ivits-growing-federation").semantics.growthMilestones, 4); + assert.equal(count("faction-lantids-shared-civilization", 'data-building="mine"'), 6); + assert.equal(count("faction-lantids-shared-civilization", 'data-building="trade"'), 6); + assert.equal(count("faction-bescods-balanced-research", 'data-level="3"'), 6); + const base = ["terra", "desert", "swamp", "oxide", "volcanic", "titanium", "ice", "gaia", "lost"]; + for (const [mode, types] of [ + ["base", base], + ["lost-fleet", [...base, "asteroid", "protoplanet"]], + ]) { + const id = `explore-all-types-${mode}`; + assert.deepEqual(item(id).semantics.planetTypes, types); + assert.equal(count(id, 'data-colony="true"'), types.length); + for (const type of types) assert.equal(count(id, `data-planet="${type}"`), 1); + } + for (const difficulty of ["automalein", "automa", "automaechtig", "ultoma", "alptrauma"]) { + const id = `win-automa-${difficulty}`; + assert.deepEqual(item(id).semantics, { difficulty, exact: true, victory: true }); + assert.equal(count(id, `data-automa-card="${difficulty}"`), 1); + } + assert.equal(count("win-mode-lost-fleet", "data-ship="), 4); + for (const a of items) assert.equal(svgFor(a).includes('data-victory="true"'), a.id.startsWith("win-")); +}); + +test("deterministic new-only SVG/PNG export, decoded images, hashes, contact sheet and preserved inputs", async () => { + const temp = await mkdtemp(path.join(os.tmpdir(), "gaia-scenes-")); + try { + await checkSources(); + const first = path.join(temp, "a"), + second = path.join(temp, "b"); + const manifest = await generateScenes(first); + assert.deepEqual(await generateScenes(second), manifest); + const files = await readdir(first); + assert.equal(files.length, 30); // 14 editable SVGs + 14 PNGs + manifest + sheet + assert.deepEqual(files, await readdir(second)); + for (const name of files) + assert.deepEqual(await readFile(path.join(first, name)), await readFile(path.join(second, name)), name); + assert.equal(new Set(manifest.assets.map((a) => a.output.sha256)).size, 14); + assert.equal(new Set(manifest.assets.map((a) => a.source.sha256)).size, 14); + for (const asset of manifest.assets) { + for (const part of [asset.source, asset.output]) + assert.equal(sha256(await readFile(path.join(first, part.path))), part.sha256); + const image = sharp(path.join(first, asset.output.path)); + const meta = await image.metadata(); + assert.equal(meta.width, 512); + assert.equal(meta.height, 512); + assert.equal(meta.format, "png"); + // Flat geometric silhouettes intentionally have less entropy than the old raster portraits. + assert.ok((await image.stats()).entropy > 1.5); + for (const size of [32, 48, 64]) { + const raw = await image.clone().resize(size).raw().toBuffer({ resolveWithObject: true }); + assert.equal(raw.info.width, size); + assert.ok(raw.data.some((v) => v > 200)); + } + } + const sheet = await sharp(path.join(first, "contact-sheet.png")).metadata(); + assert.equal(sheet.width, 1300); + assert.equal(sheet.height, 1470); + assert.deepEqual(manifest.preserved, await json("preserved-assets.json")); + assert.equal(manifest.generator.sha256, sha256(await readFile(path.join(ROOT, manifest.generator.path)))); + await checkSources(); + } finally { + await rm(temp, { recursive: true, force: true }); + } +}); diff --git a/scripts/assets/achievement-scenes/README.md b/scripts/assets/achievement-scenes/README.md new file mode 100644 index 00000000..67cf7465 --- /dev/null +++ b/scripts/assets/achievement-scenes/README.md @@ -0,0 +1,59 @@ +# Gaia achievement scenes + +Original editable geometry: `scripts/generate-achievement-scenes.mjs` (MIT, repository licence). +Related coordination: https://codeberg.org/boardgamers/boardgamers/issues/595. +The generator exports **only the 14 formerly missing assets**. It never calls the portrait +or score generator and never writes existing artwork. Generated SVGs, PNGs, source/output +SHA-256 manifest and light/dark 160/64/48/32 px contact sheet are under the ignored +`artifacts/achievement-scenes/` directory. + +## Provenance and visual vocabulary + +No downloaded images, embedded publisher art, fonts-as-outlines, SVGRepo art or existing +portrait/score pixels are included in the new badges. The geometric SVG paths are original, +not copied from the game's SVG files. Text is confined to contact-sheet labels and the +four supplementary Ivits milestone numbers; it is not the primary scene. + +Conceptual references (not licensed inputs or claims of official publisher artwork): + +- Standard Gaia building silhouettes: pitched mine, tall trading station, domed laboratory, + pyramidal institute and divided academy. Full Deployment depicts 8/4/3/1/2, respectively. +- Base mode: a colony and ordinary planet spectrum. Lost Fleet mode: the colony surrounded + by the four ship insignia, independently simplified as spiral/orbit/leaves/claw, following + the vocabulary documented in `viewer/src/components/SpaceshipEmblem.reference.md`. +- Automa: decision-card tactics with five separately arranged networks. The network layouts + are illustrations of increasing opposition, **not actual card faces or cumulative awards**. +- Federation Builder: four separate building-and-satellite groups. Ivits: one continuous + connected route with four ordered milestones, not four separate federation rewards. +- World sets: nine/eleven owned colonies, including Gaia and Lost; Fleet adds asteroid + and protoplanet. World marks are schematic surface patterns, not official planet art. +- Original faction head glyphs identify the red/ear-cased Ivits, crested aquatic Lantids, + and mechanical Bescods. These are new simplified interpretations, not recropped portraits. + Lantids depicts six host/guest pairs; Bescods six markers at level three. No victory + crown or laurel is used for any of these non-winning feats. + +The already-published 18 portraits and two score images remain untouched; their existing +provenance is not relicensed here. `preserved-assets.json` pins the verified public URLs and +full hashes; it is **not an upload list**. `preserved-sources.json` pins all faction/score +inputs and the old generator. `baseline-manifest.json` and `baseline-evaluator.sha256` pin +canonical `origin/master` commit `8861fe0121c9ea697c0b34b265f74a34fd782fc0` +(engine 4.17.9 / revision 4) for no-ID/predicate-change tests. + +## Reproduction and checks + +```sh +pnpm install --frozen-lockfile +pnpm --dir engine build +pnpm generate:achievement-scenes +pnpm test:achievement-scenes +pnpm test:achievement-portraits +pnpm --dir engine test -- --timeout 10000 +pnpm --dir engine lint +``` + +New engine is 4.17.10 / revision 5, protocol remains 0.11.0. No dependency change is +needed, so the frozen workspace lockfile remains unchanged. `GAIA_ART_PACK_ROOT` may point +the scene tests at an extracted tarball to test the exact packed hooks and packaged source. +These are author checks, **not independent review or permission to publish**. Engine POST +activates immediately: only upload after independent visual/code approval and anonymous +verification of all new named assets. Existing asset keys must not be PUT. diff --git a/scripts/assets/achievement-scenes/baseline-evaluator.sha256 b/scripts/assets/achievement-scenes/baseline-evaluator.sha256 new file mode 100644 index 00000000..cc6023d3 --- /dev/null +++ b/scripts/assets/achievement-scenes/baseline-evaluator.sha256 @@ -0,0 +1 @@ +9c875ffe7df74e24404ca42608e3a129f1caa2e3454da19898d9d802d444e1ac diff --git a/scripts/assets/achievement-scenes/baseline-manifest.json b/scripts/assets/achievement-scenes/baseline-manifest.json new file mode 100644 index 00000000..919449e2 --- /dev/null +++ b/scripts/assets/achievement-scenes/baseline-manifest.json @@ -0,0 +1,273 @@ +{ + "revision": 4, + "achievements": [ + { + "id": "win-faction-terrans", + "icon": { + "type": "asset", + "key": "achievement-faction-terrans" + }, + "name": "Terrans Victory", + "description": "Win as Terrans. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-lantids", + "icon": { + "type": "asset", + "key": "achievement-faction-lantids" + }, + "name": "Lantids Victory", + "description": "Win as Lantids. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-hadsch-hallas", + "icon": { + "type": "asset", + "key": "achievement-faction-hadsch-hallas" + }, + "name": "Hadsch Hallas Victory", + "description": "Win as Hadsch Hallas. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-ivits", + "icon": { + "type": "asset", + "key": "achievement-faction-ivits" + }, + "name": "Ivits Victory", + "description": "Win as Ivits. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-geodens", + "icon": { + "type": "asset", + "key": "achievement-faction-geodens" + }, + "name": "Geodens Victory", + "description": "Win as Geodens. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-baltaks", + "icon": { + "type": "asset", + "key": "achievement-faction-baltaks" + }, + "name": "Baltaks Victory", + "description": "Win as Baltaks. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-xenos", + "icon": { + "type": "asset", + "key": "achievement-faction-xenos" + }, + "name": "Xenos Victory", + "description": "Win as Xenos. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-gleens", + "icon": { + "type": "asset", + "key": "achievement-faction-gleens" + }, + "name": "Gleens Victory", + "description": "Win as Gleens. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-taklons", + "icon": { + "type": "asset", + "key": "achievement-faction-taklons" + }, + "name": "Taklons Victory", + "description": "Win as Taklons. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-ambas", + "icon": { + "type": "asset", + "key": "achievement-faction-ambas" + }, + "name": "Ambas Victory", + "description": "Win as Ambas. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-firaks", + "icon": { + "type": "asset", + "key": "achievement-faction-firaks" + }, + "name": "Firaks Victory", + "description": "Win as Firaks. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-bescods", + "icon": { + "type": "asset", + "key": "achievement-faction-bescods" + }, + "name": "Bescods Victory", + "description": "Win as Bescods. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-nevlas", + "icon": { + "type": "asset", + "key": "achievement-faction-nevlas" + }, + "name": "Nevlas Victory", + "description": "Win as Nevlas. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-itars", + "icon": { + "type": "asset", + "key": "achievement-faction-itars" + }, + "name": "Itars Victory", + "description": "Win as Itars. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-tinkeroids", + "icon": { + "type": "asset", + "key": "achievement-faction-tinkeroids" + }, + "name": "Tinkeroids Victory", + "description": "Win as Tinkeroids. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-darkanians", + "icon": { + "type": "asset", + "key": "achievement-faction-darkanians" + }, + "name": "Darkanians Victory", + "description": "Win as Darkanians. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-moweyds", + "icon": { + "type": "asset", + "key": "achievement-faction-moweyds" + }, + "name": "Moweyds Victory", + "description": "Win as Moweyds. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-faction-space-giants", + "icon": { + "type": "asset", + "key": "achievement-faction-space-giants" + }, + "name": "Space Giants Victory", + "description": "Win as Space Giants. Shared first place counts; either ruleset qualifies." + }, + { + "id": "win-mode-base", + "name": "Base Game Victory", + "description": "Win a Base Game game, including shared first place." + }, + { + "id": "score-base-150", + "icon": { + "type": "asset", + "key": "achievement-score-150" + }, + "name": "Base Game: 150 Points", + "description": "Finish a Base Game game with at least 150 final victory points, after auction deductions. No win required." + }, + { + "id": "score-base-200", + "icon": { + "type": "asset", + "key": "achievement-score-200" + }, + "name": "Base Game: 200 Points", + "description": "Finish a Base Game game with at least 200 final victory points, after auction deductions. No win required." + }, + { + "id": "win-mode-lost-fleet", + "name": "Lost Fleet Victory", + "description": "Win a Lost Fleet game, including shared first place." + }, + { + "id": "score-lost-fleet-150", + "icon": { + "type": "asset", + "key": "achievement-score-150" + }, + "name": "Lost Fleet: 150 Points", + "description": "Finish a Lost Fleet game with at least 150 final victory points, after auction deductions. No win required." + }, + { + "id": "score-lost-fleet-200", + "icon": { + "type": "asset", + "key": "achievement-score-200" + }, + "name": "Lost Fleet: 200 Points", + "description": "Finish a Lost Fleet game with at least 200 final victory points, after auction deductions. No win required." + }, + { + "id": "win-automa-automalein", + "name": "Defeat Automalein", + "description": "Win against Automa at exactly automalein difficulty. A tied score counts as a human win." + }, + { + "id": "win-automa-automa", + "name": "Defeat Automa", + "description": "Win against Automa at exactly automa difficulty. A tied score counts as a human win." + }, + { + "id": "win-automa-automaechtig", + "name": "Defeat Automaechtig", + "description": "Win against Automa at exactly automaechtig difficulty. A tied score counts as a human win." + }, + { + "id": "win-automa-ultoma", + "name": "Defeat Ultoma", + "description": "Win against Automa at exactly ultoma difficulty. A tied score counts as a human win." + }, + { + "id": "win-automa-alptrauma", + "name": "Defeat Alptrauma", + "description": "Win against Automa at exactly alptrauma difficulty. A tied score counts as a human win." + }, + { + "id": "build-all-standard", + "name": "Full Deployment", + "description": "Finish with all 18 standard building pieces simultaneously deployed: 8 mines, 4 trading stations, 3 research labs, the institute and both academies. Excludes Lost Planet, artifacts, Gaiaformers and space stations. No win required." + }, + { + "id": "federation-form-4", + "name": "Federation Builder", + "description": "Complete at least four federation formations in one game (extensions of the growing federation for Ivits). Token rewards and rescores do not count. No win required." + }, + { + "id": "explore-all-types-base", + "name": "Every World: Base Game", + "description": "Finish a base game with main-owned colonies on all seven ordinary planet types, Gaia and the Lost Planet. Gaiaformers and Lantids shared mines do not count. No win required." + }, + { + "id": "explore-all-types-lost-fleet", + "name": "Every World: Lost Fleet", + "description": "Finish a Lost Fleet game with main-owned colonies on all seven ordinary types, Gaia, Lost Planet, Asteroid and Protoplanet. Artifacts, Gaiaformers and Lantids shared mines do not count. No win required." + }, + { + "id": "faction-ivits-growing-federation", + "name": "Growing Federation", + "description": "As Ivits, complete at least four formation milestones of your growing federation in one game. No win required." + }, + { + "id": "faction-lantids-shared-civilization", + "name": "Shared Civilization", + "description": "As Lantids, finish with at least six additional mines on opponents' colonies. No win required." + }, + { + "id": "faction-bescods-balanced-research", + "name": "Balanced Research", + "description": "As Bescods, finish at level 3 or higher on all six research tracks. No win required." + } + ] +} diff --git a/scripts/assets/achievement-scenes/preserved-assets.json b/scripts/assets/achievement-scenes/preserved-assets.json new file mode 100644 index 00000000..adcf22e0 --- /dev/null +++ b/scripts/assets/achievement-scenes/preserved-assets.json @@ -0,0 +1,162 @@ +[ + { + "game": "gaia-project", + "key": "achievement-faction-ambas", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-ambas/d7937048f3aa6c75/achievement-faction-ambas.webp", + "bytes": 8578, + "sha256": "d7937048f3aa6c7546b31c0ca479cd5ed80a7edc215653bab3f279ca8d77de91", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-baltaks", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-baltaks/d4e2cc2591b0e088/achievement-faction-baltaks.webp", + "bytes": 8368, + "sha256": "d4e2cc2591b0e088a6f0bb41d8fed1119bf7d0556d541c89b8809bc41aee58a8", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-bescods", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-bescods/6d05714af6d47492/achievement-faction-bescods.webp", + "bytes": 9766, + "sha256": "6d05714af6d47492f6168d0dab128ceaee9f383444871cfdb33bf4555ac5c51c", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-darkanians", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-darkanians/6f11567b37a79672/achievement-faction-darkanians.webp", + "bytes": 9200, + "sha256": "6f11567b37a79672e0805e416b32f878f540af89f702c2dd9643cef8867ea6e4", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-firaks", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-firaks/187a5c29e5ebc1b1/achievement-faction-firaks.webp", + "bytes": 8514, + "sha256": "187a5c29e5ebc1b1621c178ce7473901f81d1f9b9806a7fb43b7b2c50f380c17", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-geodens", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-geodens/16ea770361a16fdf/achievement-faction-geodens.webp", + "bytes": 8838, + "sha256": "16ea770361a16fdfa98d6faca956be309dd03906afa3d0714537ddf9ef5e7248", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-gleens", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-gleens/5cd106e053ca3952/achievement-faction-gleens.webp", + "bytes": 8268, + "sha256": "5cd106e053ca39527be8d27602ef52093fbae90b3573819fb6ff9ee8e451a8a1", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-hadsch-hallas", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-hadsch-hallas/91d1136703d94477/achievement-faction-hadsch-hallas.webp", + "bytes": 8490, + "sha256": "91d1136703d944777ef09b0abcd34af439b9507f980176798a2b31668937508a", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-itars", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-itars/7240e6d9dad1ee01/achievement-faction-itars.webp", + "bytes": 7866, + "sha256": "7240e6d9dad1ee01cde60116f90f016b5049c1bed1600f63d7ab9da973d83d4b", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-ivits", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-ivits/a7cae70e778b234e/achievement-faction-ivits.webp", + "bytes": 7780, + "sha256": "a7cae70e778b234e975921bf0bcb398b175f0a1f9c935fa00888bdad88465ca4", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-lantids", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-lantids/a45146b469f0f697/achievement-faction-lantids.webp", + "bytes": 7730, + "sha256": "a45146b469f0f69743438224b12b87d5eb333451ae4dd959eb0b94732abdcb7c", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-moweyds", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-moweyds/43cf990e3907d58c/achievement-faction-moweyds.webp", + "bytes": 9238, + "sha256": "43cf990e3907d58c63c4dfba3dd92c7dc8493e30447f09e23a6f37f6ab6b3e9e", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-nevlas", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-nevlas/9150358d281068e8/achievement-faction-nevlas.webp", + "bytes": 7982, + "sha256": "9150358d281068e847f37eab4473b783d6d460b3d12a77f6ff18fa7383fb0a59", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-space-giants", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-space-giants/be1ff3af83185a17/achievement-faction-space-giants.webp", + "bytes": 9194, + "sha256": "be1ff3af83185a174d2a0175e5f80c811fb27ded1056c7859847676e1a905368", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-taklons", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-taklons/7d4ef15dfc3bc15a/achievement-faction-taklons.webp", + "bytes": 8118, + "sha256": "7d4ef15dfc3bc15ac149df6476d9c2e10fe16dfefd7b6ea5f3d26ace9658abb9", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-terrans", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-terrans/a30b9d5e3f9dbbc6/achievement-faction-terrans.webp", + "bytes": 8922, + "sha256": "a30b9d5e3f9dbbc6acdec984510f291923dd6099501c43b89dcc59c2d8646c2f", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-tinkeroids", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-tinkeroids/ddf22fc3ea7a43e7/achievement-faction-tinkeroids.webp", + "bytes": 8940, + "sha256": "ddf22fc3ea7a43e70f0806450c95945b2bfc5439ce7379387bcf2277d5ea06f6", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-faction-xenos", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-faction-xenos/3ab0339586a45d6e/achievement-faction-xenos.webp", + "bytes": 8392, + "sha256": "3ab0339586a45d6e69bbf4d4e007655b3bb9b3f5fc7580210de0e590ba719ddf", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-score-150", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-score-150/6ba2bb28578f2f20/achievement-score-150.webp", + "bytes": 16454, + "sha256": "6ba2bb28578f2f20f35835a00f5b51cdec38490b3b6e0625e921ec8eb668449a", + "hashMatches": true + }, + { + "game": "gaia-project", + "key": "achievement-score-200", + "url": "https://s3.fr-par.scw.cloud/bgs-assets/achievements/gaia-project/achievement-score-200/c2c299dc2850cd0c/achievement-score-200.webp", + "bytes": 19724, + "sha256": "c2c299dc2850cd0c94acd11e21e5a56a6ae691b580458d0906a514625154796b", + "hashMatches": true + } +] diff --git a/scripts/assets/achievement-scenes/preserved-sources.json b/scripts/assets/achievement-scenes/preserved-sources.json new file mode 100644 index 00000000..8e4c5586 --- /dev/null +++ b/scripts/assets/achievement-scenes/preserved-sources.json @@ -0,0 +1,29 @@ +{ + "scripts/generate-achievement-portraits.mjs": "6593ede72a2ff0cfd16b04dcafdb9fdf009b186a87a35024ea07fbbc08ec935b", + "viewer/src/assets/factions/geodens.jpg": "915067d842c34e3ed8907011391935e196464681af36647a0be3eec7f2ba3a6e", + "viewer/src/assets/factions/mowyeds.jpg": "9ee2bf809ab77a6362b148bdf865c82c7ca67854570222316ac28765959dcdaf", + "viewer/src/assets/factions/hadsch-hallas.jpg": "a802d0425503db30a660905aaf9378b1caf8731c9d259664e5fa0cba7b50f950", + "viewer/src/assets/factions/ambas.jpg": "75ee8098fb6b76445d4a580a47a24a3fd444575d23124dbf0e4cf2957b553fed", + "viewer/src/assets/factions/darkanians.jpg": "312687adedc5faf74b61ea8f608bd6f505c1ac9a836ae537fb15dd87da77d81b", + "viewer/src/assets/factions/terrans.jpg": "36e356e4de96a96b481244fa6d2a774ab71498d81fe2ca73df0eff2dc12614ad", + "viewer/src/assets/factions/itars.jpg": "a83f4affbebdecbdbadf06d38bbea1e06db0f2bc1a635ba9b7bb9b61ea13f2cc", + "viewer/src/assets/factions/taklons.jpg": "437eeac297fe498a51542c7ce6fcb02794558df1c651204d6cc1ab2d8ae5063f", + "viewer/src/assets/factions/nevlas.jpg": "e5c464d4e423ae252984f7224fa48063d3966331169c9defb411f719d96d9ccf", + "viewer/src/assets/factions/README.md": "9f1f3ab12edf62c33298f1affd36d702080b8ac48666a5a0ba0a203053205132", + "viewer/src/assets/factions/firaks.jpg": "d6a04fc4fe9b2426cf4c04e26974f32c6dff7b70503e7a05bc4672b2da8a9ca8", + "viewer/src/assets/factions/tinkeroids.jpg": "7aa4f8725c3feb39ac68a25366185108d24fcf27b33aebb4f140eed30d108144", + "viewer/src/assets/factions/baltaks.jpg": "84e74163497a5b90b9dde76d72ff2e130fa31b88f46486400090d0577ebde68e", + "viewer/src/assets/factions/space-giants.jpg": "fd232a4a41658f4545fc90dd991db496bc8e028b10d914935615b869d20cc64a", + "viewer/src/assets/factions/bescods.jpg": "aac494b6ca9ae7e1acc18fdfa69241f07b6a111296c8973746b8c2c5e2467c6a", + "viewer/src/assets/factions/xenos.jpg": "a5d61249be68a07b3109cf3d3e0238e828bd21423e106e1038bdcd235d006ce7", + "viewer/src/assets/factions/ivits.jpg": "e0307d8944befe8f991f685834d9d02a5ff89f472793be8a018552e819aeaec9", + "viewer/src/assets/factions/lantids.jpg": "2332ee2596e6a6ecdfac00c9a3f4bfc7186d57ac1bd319d11ccae9c7f0d8e811", + "viewer/src/assets/factions/gleens.jpg": "0fcaa4fc1e6948bebdc8b7094faa5b97f14381d1c18e5ad5bf39cc212f28539b", + "scripts/assets/achievement-scores/digit-0.png": "cbdbb951c1de0da3d280249c8197e9b66146ad3f3ca6920717049057117ca3ce", + "scripts/assets/achievement-scores/digit-1.png": "a1c07e26fe5cfa1b58552a7fd18723434d6d46c58fe1ffadbd831f94daac7d1c", + "scripts/assets/achievement-scores/README.md": "0bfe44dca14805669c00eaaea637ef95fec844311630bda15d0176f348c9df74", + "scripts/assets/achievement-scores/FONT-LICENSE.txt": "562c8f5e92af7a06339292a1bb0b9a3e9c8d5142af5d7167f2866fc50261b993", + "scripts/assets/achievement-scores/digit-5.png": "65975965deb89c3b546218ade0f2af28fecb4921278e1fa961a51568242e9b19", + "scripts/assets/achievement-scores/digit-2.png": "f38ce297ccdd1b470e1e4a48210617d90a7a6e410570d303cfdf358be002e525", + "scripts/assets/achievement-scores/gaia-pictogram.webp": "09bdce75fb8e0020a1b52e9e4352d62bced93b117e94704549e0662e04093a62" +} diff --git a/scripts/generate-achievement-scenes.mjs b/scripts/generate-achievement-scenes.mjs new file mode 100644 index 00000000..fa5781ef --- /dev/null +++ b/scripts/generate-achievement-scenes.mjs @@ -0,0 +1,391 @@ +// Original geometric achievement scenes, MIT. No publisher raster/vector assets are embedded. +import { createHash } from "node:crypto"; +import { mkdir, readFile, writeFile } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import sharp from "sharp"; + +export const ROOT = fileURLToPath(new URL("../", import.meta.url)); +export const OUTPUT = path.join(ROOT, "artifacts/achievement-scenes"); +export const sha256 = (b) => createHash("sha256").update(b).digest("hex"); +const ink = "#10283d", + paper = "#ecf5f1", + gold = "#ffce72", + teal = "#65d6c0"; +const circle = (x, y, r, fill, extra = "") => ``; +const line = (x, y, X, Y, color = teal, w = 3) => + ``; +const shape = (d, fill = paper, extra = "") => + ``; +const group = (x, y, s, body, extra = "") => `${body}`; +function building(type, x, y, s = 1, color = paper) { + const paths = { + mine: "M-12 10V-4L0 -14L12 -4V10L0 17Z M-12 -4L0 3L12 -4 M0 3V17", + trade: "M-12 15V-5L-4 -5V-18H8V-5H14V15Z", + lab: "M-16 12C-16 -22 16 -22 16 12Q0 22 -16 12Z", + institute: "M-22 13L0 -23L22 13L0 24Z M0 -23V24", + academy: "M-17 16V-13H-5V-23H6V-13H17V16Z M-17 0H17 M0 -23V16", + }; + return group(x, y, s, shape(paths[type], color), `data-building="${type}"`); +} +const planets = [ + ["terra", "#5599e4"], + ["desert", "#e9c464"], + ["swamp", "#aa8058"], + ["oxide", "#e97565"], + ["volcanic", "#777e8d"], + ["titanium", "#d4d8dd"], + ["ice", "#9edfe9"], + ["gaia", "#8fd080"], + ["lost", "#b998e2"], + ["asteroid", "#bca7a1"], + ["protoplanet", "#e994c5"], +]; +function world(index, x, y, r = 16, colony = true) { + const [name, color] = planets[index]; + let body = + index === 9 + ? shape(`M${-r} 0L${-r * 0.5} ${-r}L${r * 0.7} ${-r * 0.8}L${r} ${r * 0.4}L0 ${r}Z`, color) + : circle(0, 0, r, color, `stroke="${paper}" stroke-width="1.5"`); + // Surface bands remain distinct in grayscale; Gaia sprouts, Lost has an orbit. + if (index === 7) body += shape("M0 9V-6Q-12 -12 -8 -1L0 4Q10 -12 12 -7L0 4", ink); + else if (index === 8) + body += ``; + else if (index === 10) body += circle(0, 0, r * 0.5, ink) + circle(0, 0, r * 0.2, gold); + else body += line(-r * 0.6, r * 0.2, r * 0.5, -r * 0.45, ink, 2); + if (colony) body += building("mine", 0, -2, r / 30, paper); + return group(x, y, 1, body, `data-planet="${name}" data-colony="${colony}"`); +} +function victory() { + return ( + `${[0, 1, 2].map((i) => ``).join("")}` + + shape("M113 53L110 39L121 45L128 32L135 45L146 39L143 53Z", gold) + ); +} +function colony(x = 128, y = 147, s = 1) { + return group( + x, + y, + s, + circle(0, 14, 42, "#3478a1") + + `` + + building("institute", 0, -4, 1.15) + + building("mine", -27, 17, 0.62, teal) + + building("trade", 27, 10, 0.65, teal) + ); +} +function ship(x, y, kind) { + const colors = ["#b895c7", "#ddca76", "#ccd7dd", "#b78d70"]; + const signs = [ + ``, + `` + + circle(0, 0, 6, ink), + shape("M-9 8L-3 -9L2 -4Z M0 9L10 -8L11 1Z", ink), + shape("M-10 -9L-5 7L0 11L5 7L10 -9L5 1L0 -3L-5 1Z", ink), + ]; + return group( + x, + y, + 1, + shape("M-25 8L-20 -7L0 -21L20 -7L25 8L0 19Z", colors[kind]) + signs[kind], + `data-ship="${["twilight", "eclipse", "tf-mars", "rebellion"][kind]}"` + ); +} +function factionHead(faction) { + let body; + if (faction === "ivits") + body = + shape("M-12 -19H12L16 7L8 23H-8L-16 7Z", "#e97854") + + `` + + line(0, -15, 0, 14, ink, 3); + if (faction === "lantids") + body = + shape("M-23 20L-16 -12L-5 -22L0 -30L5 -22L16 -12L23 20L10 10L0 24L-10 10Z", "#99c9df") + + shape("M-12 -1L-5 3M12 -1L5 3", "none") + + line(-5, 14, 5, 14, gold, 3); + if (faction === "bescods") + body = + shape("M-18 -19H13L20 -8V18H-17Z", "#bcc8c8") + + shape("M-21 -8H21V1H-21Z", gold) + + circle(-7, -4, 3, ink) + + circle(8, -4, 3, ink) + + shape("M-9 8H9V20H-9Z", ink) + + line(0, 10, 0, 17, teal, 3); + return group(128, 65, 1, body, `data-faction="${faction}"`); +} +const scene = (id, title, semantics, body) => ({ id, title, semantics, body }); +export function scenes() { + const out = []; + out.push( + scene( + "win-mode-base", + "Base Game Victory", + { mode: "base", victory: true }, + victory() + [0, 1, 2, 3, 4, 5, 6].map((p, i) => world(p, 68 + i * 20, 88, 8, false)).join("") + colony() + ) + ); + out.push( + scene( + "win-mode-lost-fleet", + "Lost Fleet Victory", + { mode: "lost-fleet", victory: true, ships: 4 }, + victory() + ship(82, 93, 0) + ship(174, 93, 1) + ship(77, 166, 2) + ship(179, 166, 3) + colony(128, 139, 0.72) + ) + ); + const difficulties = ["automalein", "automa", "automaechtig", "ultoma", "alptrauma"]; + difficulties.forEach((d, i) => { + // Five different tactical layouts; no stack of cumulative rank stars. + const layouts = [ + [[128, 106]], + [ + [98, 92], + [157, 92], + [128, 120], + ], + [ + [91, 83], + [128, 83], + [165, 83], + [106, 116], + [150, 116], + ], + [ + [85, 94], + [128, 76], + [171, 94], + [87, 135], + [169, 135], + ], + [ + [85, 84], + [128, 70], + [171, 84], + [77, 120], + [179, 120], + [100, 144], + [156, 144], + ], + ]; + const nodes = layouts[i]; + let body = shape("M70 66H186V156H70Z", "#234157", `data-automa-card="${d}"`); + body += nodes + .slice(1) + .map(([x, y], j) => line(nodes[j][0], nodes[j][1], x, y, "#c38eb7", 3)) + .join(""); + body += nodes + .map(([x, y], j) => + group(x, y, 0.65, j % 2 ? shape("M-12 -12H12V12H-12Z", "#dca4ca") : shape("M0 -15L14 0L0 15L-14 0Z", "#dca4ca")) + ) + .join(""); + body += colony(128, 166, 0.69) + victory(); + out.push(scene(`win-automa-${d}`, `Defeat ${d}`, { difficulty: d, exact: true, victory: true }, body)); + }); + let all = ""; + [ + ["mine", 8, 169, 0.58], + ["trade", 4, 135, 0.78], + ["lab", 3, 96, 0.82], + ["institute", 1, 52, 0.78], + ["academy", 2, 52, 0.74], + ].forEach(([type, n, y, s]) => { + for (let i = 0; i < n; i++) { + const x = + type === "institute" + ? 128 + : type === "academy" + ? 81 + i * 94 + : 128 + (i - (n - 1) / 2) * (type === "mine" ? 20 : 34); + all += building(type, x, y, s, type === "mine" ? teal : paper); + } + }); + out.push( + scene( + "build-all-standard", + "Full Deployment", + { buildings: { mine: 8, trade: 4, lab: 3, institute: 1, academy: 2 } }, + all + `` + ) + ); + let formations = ""; + [ + [85, 83], + [170, 83], + [85, 164], + [170, 164], + ].forEach(([x, y]) => { + formations += group( + x, + y, + 1, + `${line(-15, -12, 16, 5)}${line(16, 5, -12, 23)}${line(-15, -12, 22, -18)}${circle(22, -18, 4, gold)}${building("institute", -15, -12, 0.7)}${building("academy", 16, 5, 0.65)}${building("mine", -12, 23, 0.65)}` + ); + }); + out.push(scene("federation-form-4", "Four Formations", { formations: 4 }, formations)); + for (const fleet of [false, true]) { + const n = fleet ? 11 : 9; + const positions = fleet + ? [ + [92, 55], + [128, 51], + [164, 55], + [71, 95], + [109, 96], + [147, 96], + [185, 95], + [77, 142], + [128, 140], + [179, 142], + [128, 185], + ] + : [ + [84, 66], + [128, 61], + [172, 66], + [77, 119], + [128, 115], + [179, 119], + [84, 171], + [128, 177], + [172, 171], + ]; + out.push( + scene( + `explore-all-types-${fleet ? "lost-fleet" : "base"}`, + `Every World: ${fleet ? "Lost Fleet" : "Base"}`, + { planetTypes: planets.slice(0, n).map((p) => p[0]), mainOwned: true }, + positions.map(([x, y], i) => world(i, x, y, 17)).join("") + ) + ); + } + let growth = factionHead("ivits"); + const points = [ + [69, 159], + [105, 128], + [148, 158], + [187, 125], + ]; + growth += ``; + points.forEach(([x, y], i) => { + growth += + circle(x, y, 21, "#254b5b") + + building(i === 0 ? "institute" : "mine", x, y, 0.8) + + circle(x, y + 28, 7, gold) + + `${i + 1}`; + }); + out.push( + scene( + "faction-ivits-growing-federation", + "Ivits: Growing Federation", + { faction: "ivits", connectedFederations: 1, growthMilestones: 4 }, + growth + ) + ); + let shared = factionHead("lantids"); + [ + [78, 124], + [128, 124], + [178, 124], + [78, 176], + [128, 176], + [178, 176], + ].forEach(([x, y], i) => { + shared += + world(i, x, y, 19, false) + building("trade", x - 7, y, 0.58, gold) + building("mine", x + 9, y + 7, 0.53, teal); + }); + out.push( + scene( + "faction-lantids-shared-civilization", + "Lantids: Shared Civilization", + { faction: "lantids", sharedMines: 6 }, + shared + ) + ); + let research = factionHead("bescods") + line(62, 128, 194, 128, gold, 3); + for (let i = 0; i < 6; i++) { + const x = 68 + i * 24; + research += `` + line(x, 188, x, 105, "#537185", 5); + for (let j = 0; j < 4; j++) research += line(x - 6, 188 - j * 20, x + 6, 188 - j * 20, paper, 2); + research += shape(`M${x} 119L${x + 8} 128L${x} 137L${x - 8} 128Z`, teal) + ``; + } + out.push( + scene( + "faction-bescods-balanced-research", + "Bescods: Balanced Research", + { faction: "bescods", tracks: 6, minimumLevel: 3 }, + research + ) + ); + return out; +} +export function svgFor(item) { + return `${item.title}${circle(128, 128, 124, ink)}${circle(128, 128, 117, "none", `stroke="#5e8494" stroke-width="2"`)}${item.body}`; +} +export async function generateScenes(output = OUTPUT) { + await mkdir(output, { recursive: true }); + const assets = []; + const layers = []; + for (const [i, item] of scenes().entries()) { + const key = `achievement-${item.id}`, + svg = Buffer.from(svgFor(item)); + const png = await sharp(svg).png({ compressionLevel: 9 }).toBuffer(); + await writeFile(path.join(output, `${key}.svg`), svg); + await writeFile(path.join(output, `${key}.png`), png); + assets.push({ + id: item.id, + key, + semantics: item.semantics, + source: { path: `${key}.svg`, sha256: sha256(svg) }, + output: { path: `${key}.png`, sha256: sha256(png), width: 512, height: 512 }, + }); + const x = (i % 2) * 650, + y = Math.floor(i / 2) * 210; + layers.push({ input: await sharp(png).resize(160).toBuffer(), left: x + 12, top: y + 32 }); + for (const [j, size] of [64, 48, 32].entries()) + for (const [k, bg] of ["#f5f3e9", "#10202d"].entries()) { + const icon = await sharp(png).resize(size).flatten({ background: bg }).toBuffer(); + layers.push({ + input: await sharp({ create: { width: 80, height: 80, channels: 3, background: bg } }) + .composite([{ input: icon, left: Math.floor((80 - size) / 2), top: Math.floor((80 - size) / 2) }]) + .png() + .toBuffer(), + left: x + 195 + j * 86, + top: y + 35 + k * 82, + }); + } + const label = Buffer.from( + `${item.title} ยท 160 / 64 / 48 / 32 px` + ); + layers.push({ input: label, left: x, top: y }); + } + await sharp({ create: { width: 1300, height: 1470, channels: 3, background: "#203747" } }) + .composite(layers) + .png() + .toFile(path.join(output, "contact-sheet.png")); + const preserved = JSON.parse( + await readFile(path.join(ROOT, "scripts/assets/achievement-scenes/preserved-assets.json"), "utf8") + ); + const manifest = { + schemaVersion: 1, + game: "gaia-project", + engineVersion: "4.17.10", + revision: 5, + baseline: { engineVersion: "4.17.9", revision: 4, commit: "8861fe0121c9ea697c0b34b265f74a34fd782fc0" }, + provenance: { + license: "MIT", + author: "Original geometric artwork authored for boardgamers/gaia-project, 2026", + inputs: [], + references: + "Game vocabulary only: standard pieces, planet types, Lost Fleet four named insignia and existing faction identities. No external or existing image bytes copied; preserved assets excluded from generation.", + }, + generator: { + path: "scripts/generate-achievement-scenes.mjs", + sha256: sha256(await readFile(fileURLToPath(import.meta.url))), + }, + toolchain: sharp.versions, + assets, + preserved, + }; + await writeFile(path.join(output, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n"); + return manifest; +} +if (process.argv[1] === fileURLToPath(import.meta.url)) await generateScenes(process.argv[2]);