Skip to content

feat(api): NPC place/move/remove on worldBuilder drafts (#8) - #358

Open
Aduersarius wants to merge 1 commit into
Bitcoindefi:mainfrom
Aduersarius:feat/map-npc-place-move-api-8
Open

feat(api): NPC place/move/remove on worldBuilder drafts (#8)#358
Aduersarius wants to merge 1 commit into
Bitcoindefi:mainfrom
Aduersarius:feat/map-npc-place-move-api-8

Conversation

@Aduersarius

Copy link
Copy Markdown

Summary

Ships OpenAO #8 on top of the existing /construccion world-builder draft/publish stack.

  • Place / move / remove / list NPCs as game_map_tile_entities drafts (kind=npc)
  • Catalog check against game_npcs (404 + invalid_npc_index)
  • Blocked-tile rejection from terrain.json palette/rows + layer-1 draft/published overrides
  • No stacking on an occupied tile; MAX_NPCS_PER_MAP = 50 as a single named constant
  • Self-tile move is a no-op success (maintainer note on Etapa 2: API de colocacion y movimiento de NPCs en mapa #8)
  • Optional movement stored in entity meta and copied on publish
  • Pure helpers + unit tests: api/src/lib/mapNpcPlacement.ts, api/src/tests/mapNpcPlacement.test.ts (7/7)

Closes #8

Admin routes

  • GET /admin/game-data/maps/:mapNum/npcs
  • POST /admin/game-data/maps/:mapNum/npcs
  • POST /admin/game-data/maps/:mapNum/npcs/move
  • DELETE /admin/game-data/maps/:mapNum/npcs/:x/:y

Differentiation vs open PRs

PR Gap vs this
#66 (angelTomo9) In-memory map-npc-service kitchen-sink (exits/moderation/protocol/FE). Fake catalog bounds 1–340, not wired to real drafts/Postgres. This PR is #8-only on the live worldBuilder draft/publish path.
#135 (Rodrigoue9) Patrol waypoint generator is unused/untested dead code + unrelated draft file. Does not deliver place/move/remove HTTP + persistence.
#218 (Rodrigoue9, assigned) Mutates seed npcs.json on disk outside the draft/publish model. No blocked check against draft tile overrides, no meta.movement publish survival. This PR uses Postgres drafts, terrain+override collision, named limit, and self-move no-op.

Test plan

  • cd api && npx tsx --test src/tests/mapNpcPlacement.test.ts (7/7)
  • Apply schema (meta column)
  • Admin: place NPC with movement → list → move → self-move no-op → remove
  • Unknown npcIndex → 404
  • Place on blocked terrain tile → 400 tile_blocked
  • Second NPC same tile → 400 tile_occupied
  • 51st NPC → 400 map_npc_limit
  • Publish → GET /maps/:id/overrides entities include npc + meta.movement

No txs/keys/funds involved.

Wire construction-mode NPC placement into Postgres drafts with catalog,
blocked-terrain, no-stack, and MAX_NPCS_PER_MAP checks. Self-tile moves
are a no-op success. movement persists in entity meta through publish.
@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 2: API de colocacion y movimiento de NPCs en mapa

1 participant