feat(worldBuilder): implement floor objects, multi-tile structures and door collision states (#9) - #78
feat(worldBuilder): implement floor objects, multi-tile structures and door collision states (#9)#78Rodrigoue9 wants to merge 7 commits into
Conversation
# Conflicts: # .github/workflows/ci.yml
| /** Mueve todas las versiones de un objeto sin dejar estados parciales. */ | ||
| export async function moveMapObject( | ||
| input: MoveMapObjectInput, | ||
| accountId: string, | ||
| ): Promise<{ ok: true; movedVersions: number }> { | ||
| const parsed = moveMapObjectSchema.parse(input); | ||
| const client = await pool.connect(); | ||
|
|
||
| try { | ||
| await client.query("BEGIN"); | ||
| await client.query("SELECT pg_advisory_xact_lock($1, $2)", [ | ||
| PLACEMENT_LOCK_NAMESPACE, | ||
| parsed.mapNum, | ||
| ]); | ||
| const result = await client.query( |
There was a problem hiding this comment.
💡 Quality: moveMapObject/removeMapObject mutate published rows, skipping publish
placeMapObject writes only draft rows (status='draft'), so edits require an explicit publish step. moveMapObject and removeMapObject instead mutate/delete all statuses including 'published', so moving or deleting an object changes the live map immediately with no draft/preview/publish cycle. This is inconsistent with the rest of the world-builder workflow and can surprise admins by altering what players see before publishing. Consider scoping these to drafts (or making the live mutation an explicit, documented behavior).
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 8 resolved / 9 findingsImplements floor objects, multi-tile structures, and door collision states with comprehensive test coverage and atomic database transactions. The placement workflow is solid, but 💡 Quality: moveMapObject/removeMapObject mutate published rows, skipping publish📄 api/src/repositories/worldBuilder.ts:1007-1021 📄 api/src/repositories/worldBuilder.ts:962-976 placeMapObject writes only draft rows (status='draft'), so edits require an explicit publish step. moveMapObject and removeMapObject instead mutate/delete all statuses including 'published', so moving or deleting an object changes the live map immediately with no draft/preview/publish cycle. This is inconsistent with the rest of the world-builder workflow and can surprise admins by altering what players see before publishing. Consider scoping these to drafts (or making the live mutation an explicit, documented behavior). ✅ 8 resolved✅ Bug: placeMapObject stores objIndex in grh_index and drops amount
✅ Edge Case: Doors and structures share layer 3, causing overwrite collisions
✅ Quality: Tests only cover zod schemas, not DB placement logic
✅ Edge Case: structureTileSchema offsets unbounded before origin bounds check
✅ Edge Case: Published objects/doors cannot be removed via delete endpoint
...and 3 more resolved from earlier reviews 🤖 Prompt for agentsOptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Important Your trial ends in 3 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more. Was this helpful? React with 👍 / 👎 | Gitar |
📌 Summary
Fixes #9
Implements Etapa 2 (Construcción del Mundo): Placement, movement, and removal of floor objects, multi-tile structures across layers 3 and 4, and interactive doors with blocking state synchronization.
🛠️ Key Implementation Details
Floor Objects (
placeMapObject,removeMapObject):objIndexagainst the active catalog ingame_objectsbefore placement.1..MAP_SIZE).game_map_tile_overrides.Multi-Tile Structures (
placeStructure):BEGIN...COMMIT / ROLLBACK) to prevent partial placement.Door State & Collision Management (
setDoorState):openGrhIndexandclosedGrhIndex.blocked: truewhen closed,blocked: falsewhen open.🧪 Verification & Testing
api/src/tests/worldBuilder.unit.test.ts.🤝 Bounty Reference
Addresses bounty issue #9 (Etapa 2: colocacion de objetos, estructuras y puertas) under the GrantFox OSS reward program.