Skip to content

feat(api): PNG→engine graphics index + map palette extensions (#6) - #359

Open
Aduersarius wants to merge 1 commit into
Bitcoindefi:mainfrom
Aduersarius:feat/png-engine-palette-6
Open

feat(api): PNG→engine graphics index + map palette extensions (#6)#359
Aduersarius wants to merge 1 commit into
Bitcoindefi:mainfrom
Aduersarius:feat/png-engine-palette-6

Conversation

@Aduersarius

Copy link
Copy Markdown

Summary

Resolves #6 — bridge uploaded PNGs into the engine grhIndex space and let admins add reusable palette entries (layers + blocked) without rewriting terrain.json.

What landed

  • Reserved range documented (docs/uploaded-graphics-range.md): UPLOADED_GRAPHIC_INDEX_START = 1_000_000 shared across API, schema CHECK, and client gameLoader.
  • Catalog-aware validation (graphicCatalog.ts): originals must exist in real graficos(_optimized).json; uploaded IDs must exist in game_uploaded_graphics. No hardcoded “max engine id” loophole.
  • GET /game-data/graphics/index: graficos.json-shaped index for uploaded assets (complements existing metadata list + client mergeUploadedGraphics).
  • Palette CRUD: PUT/DELETE /admin/game-data/maps/:mapNum/palettegame_map_palette_overrides (JSONB layers preserve nulls). Merged into GET .../terrain.
  • paintTiles: validates every referenced grh against the same catalog.
  • Editor client helpers for palette upsert/delete.
  • Tests: npx tsx --test src/tests/graphicCatalogPalette.test.ts → 5/5.

Differentiation vs open PRs

PR Gap
#111 Schema/validate only; no palette create API; vitest mocks; unrelated idle-ping edit; accepts any ID ≤ 320151 without checking graficos.json
#69 Kitchen-sink PR; wrong reserved range 50000–99999 (collides with optimized catalog max >52k); invents parallel services/ tree
#130 Palette table idea is close, but bundles map-permissions + SES email noise; originals “validated” as fake 32×32 stubs, not graficos.json

This PR stays on the existing worldBuilder / construction-mode path from #33, adds only what #6 asks for, and validates against the real engine catalog.

Test plan

  • cd api && npx tsx --test src/tests/graphicCatalogPalette.test.ts (5/5)
  • Apply api/schema.sql (new game_map_palette_overrides)
  • Upload PNG → confirm grhIndex >= 1_000_000 and appears in GET /game-data/graphics + /graphics/index
  • PUT /admin/game-data/maps/1/palette with { "graphics": [<uploaded>, null], "blocked": true } → entry appears in GET .../terrain
  • Reference missing uploaded / missing engine ID → 400 validation error
  • DELETE .../palette/:id removes override only (terrain.json untouched)

…ttes (Bitcoindefi#6)

Bridge construction-mode PNGs into the shared grhIndex space with catalog
validation against graficos.json (not a hardcoded ceiling), expose a
graficos-shaped uploaded index, and let admins add palette entries
(layers + blocked) via Postgres overrides merged into terrain reads.
@gitar-bot

gitar-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Etapa 1: registrar PNG subidos como graficos del motor y extender la paleta

1 participant