From 00197982b7fa33067c8e00150f1d867a7eb28ef6 Mon Sep 17 00:00:00 2001 From: Natalie Date: Sat, 18 Apr 2026 02:22:23 -0700 Subject: [PATCH] =?UTF-8?q?feat(@projects/@magic-civilization):=20?= =?UTF-8?q?=E2=9C=A8=20add=20sprite=20detection=20utilities=20for=20new=20?= =?UTF-8?q?asset=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../pages/progress-report/assets-detection.ts | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/public/games/age-of-dwarves/guide/src/pages/progress-report/assets-detection.ts b/public/games/age-of-dwarves/guide/src/pages/progress-report/assets-detection.ts index 16eaa7fe..c16e0d70 100644 --- a/public/games/age-of-dwarves/guide/src/pages/progress-report/assets-detection.ts +++ b/public/games/age-of-dwarves/guide/src/pages/progress-report/assets-detection.ts @@ -24,6 +24,26 @@ interface BuildingEntry { sprite?: string } +interface ItemEntry { + id?: string + sprite?: string +} + +interface DepositEntry { + id?: string + sprite?: string +} + +interface FaunaEntry { + id?: string + sprite?: string +} + +interface WonderEntry { + id?: string + sprite?: string +} + /** Strip a leading `audio/` or `sprites/` segment so expected paths align with * the layout under `public/games/age-of-dwarves/assets/`. */ function normaliseAssetPath(raw: string): string { @@ -73,6 +93,41 @@ export function collectExpectedBuildingSpritePaths(buildingFiles: BuildingEntry[ return Array.from(paths).sort() } +/** Single-entry-per-file shape (items, deposits, fauna species). Each JSON + * is one object with an optional `sprite` path. */ +function collectSinglePerFile(files: ReadonlyArray<{ sprite?: string }>): string[] { + const paths = new Set() + for (const entry of files) { + if (entry?.sprite) paths.add(normaliseAssetPath(entry.sprite)) + } + return Array.from(paths).sort() +} + +export function collectExpectedItemSpritePaths(itemFiles: ItemEntry[]): string[] { + return collectSinglePerFile(itemFiles) +} + +export function collectExpectedResourceSpritePaths(depositFiles: DepositEntry[]): string[] { + return collectSinglePerFile(depositFiles) +} + +export function collectExpectedFaunaSpritePaths(faunaFiles: FaunaEntry[]): string[] { + return collectSinglePerFile(faunaFiles) +} + +/** Mundane wonders live as a single JSON array of building-shaped entries + * (`data/buildings/mundane_wonders.json`). Same shape as unit/building + * arrays-of-arrays passed elsewhere, but with exactly one outer file. */ +export function collectExpectedWonderSpritePaths(wonderFiles: WonderEntry[][]): string[] { + const paths = new Set() + for (const arr of wonderFiles) { + for (const w of arr) { + if (w.sprite) paths.add(normaliseAssetPath(w.sprite)) + } + } + return Array.from(paths).sort() +} + /** Given a set of expected asset paths and a set of present asset paths * (as returned by `import.meta.glob` keys, already normalised), compute a * per-item presence record. `presentPaths` should contain the same relative