feat(npcs): implement map NPC placement and boundary-aware patrol path generator (#8) - #135
Conversation
| for (const off of offsets) { | ||
| const targetX = Math.min(Math.max(startX + off.dx, mapBounds.minX), mapBounds.maxX); | ||
| const targetY = Math.min(Math.max(startY + off.dy, mapBounds.minY), mapBounds.maxY); | ||
| waypoints.push({ x: targetX, y: targetY, step: step++ }); | ||
| } |
There was a problem hiding this comment.
💡 Edge Case: Patrol waypoints collapse to duplicates near map edges
Because each waypoint is independently clamped to mapBounds, an NPC placed near a boundary produces repeated/adjacent coordinates (e.g. startX=1, radius=3: offsets dx=0 and dx=-3 both clamp to x=1), so the 'patrol' degenerates into standing still or a jittery back-and-forth. Consider skipping waypoints that were clamped (out-of-bounds) or de-duplicating consecutive identical points so the generated path stays meaningful at edges.
Was this helpful? React with 👍 / 👎
| # feat(world-builder): register uploaded graphics and extend palette schemas (#6) | ||
|
|
||
| ## Summary | ||
| Resolves #6 by providing `paletteEntrySchema` and `validatePaletteEntry` to validate multi-layer palette definitions, enforce non-colliding graphic index allocations (`UPLOADED_GRAPHIC_INDEX_START = 1_000_000`), and verify graphic existence across engine and uploaded assets. | ||
|
|
||
| ### Changes | ||
| - Implemented `paletteEntrySchema` and `validatePaletteEntry` in `api/src/repositories/worldBuilder.ts`. | ||
| - Added unit tests in `api/src/repositories/__tests__/paletteValidation.test.ts`. | ||
|
|
||
| Closes #6 |
There was a problem hiding this comment.
💡 Quality: Stray PR_DESCRIPTION_DRAFT.md unrelated to this PR committed
This new file at repo root is a draft PR description for a different issue (#6, world-builder palette schemas) and is unrelated to the NPC placement/patrol feature. It appears to be an accidental commit; remove it before merging to avoid polluting the repository root.
Was this helpful? React with 👍 / 👎
| export interface NpcPlacementConfig { | ||
| npcId: number; | ||
| mapId: number; | ||
| x: number; | ||
| y: number; | ||
| heading: number; | ||
| patrolRadius?: number; | ||
| } |
There was a problem hiding this comment.
💡 Quality: Patrol generator and config type are unused / untested
generatePatrolWaypoints has no callers anywhere in the codebase and NpcPlacementConfig (including patrolRadius) is never referenced, so the feature is effectively dead code with no unit tests despite the PR being about patrol generation. Wire the generator into the NPC placement flow and add tests covering boundary clamping, otherwise it cannot be validated and may silently rot.
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 3 findingsImplements map NPC placement and a boundary-aware patrol path generator. Consider cleaning up the unrelated PR draft file, removing dead code or adding tests for the unused patrol generator, and fixing waypoint duplication near map edges. 💡 Edge Case: Patrol waypoints collapse to duplicates near map edges📄 api/src/repositories/mapNpcPlacement.ts:39-43 Because each waypoint is independently clamped to mapBounds, an NPC placed near a boundary produces repeated/adjacent coordinates (e.g. startX=1, radius=3: offsets dx=0 and dx=-3 both clamp to x=1), so the 'patrol' degenerates into standing still or a jittery back-and-forth. Consider skipping waypoints that were clamped (out-of-bounds) or de-duplicating consecutive identical points so the generated path stays meaningful at edges. 💡 Quality: Stray PR_DESCRIPTION_DRAFT.md unrelated to this PR committed📄 PR_DESCRIPTION_DRAFT.md:1-10 This new file at repo root is a draft PR description for a different issue (#6, world-builder palette schemas) and is unrelated to the NPC placement/patrol feature. It appears to be an accidental commit; remove it before merging to avoid polluting the repository root. 💡 Quality: Patrol generator and config type are unused / untested📄 api/src/repositories/mapNpcPlacement.ts:4-11 📄 api/src/repositories/mapNpcPlacement.ts:19-33 generatePatrolWaypoints has no callers anywhere in the codebase and NpcPlacementConfig (including patrolRadius) is never referenced, so the feature is effectively dead code with no unit tests despite the PR being about patrol generation. Wire the generator into the NPC placement flow and add tests covering boundary clamping, otherwise it cannot be validated and may silently rot. 🤖 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 7 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more. Was this helpful? React with 👍 / 👎 | Gitar |
Resumen de la Solución (Issue #8)
generatePatrolWaypoints).Closes #8
Resolves #8
Listo para revisión! 🚀
Summary by Gitar
clan_members,clan_requests, andclan_idsupport inapi/schema.sqlapi/src/jsons/npcs.jsonThis will update automatically on new commits.