Skip to content

feat(location): entity movement + occupancy/collision (#146, #147)#152

Merged
dmccoystephenson merged 1 commit into
mainfrom
feat/146-147-movement-collision
Jun 14, 2026
Merged

feat(location): entity movement + occupancy/collision (#146, #147)#152
dmccoystephenson merged 1 commit into
mainfrom
feat/146-147-movement-collision

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Closes #146 and #147 — two coupled Viron responsibilities from RFC 0001 that didn't exist: validate and apply movement, and spatial queries / collision detection. Movement validation is where the collision check lives, so they're delivered together.

Occupancy / collision (#147)

  • LocationRepository.getEntityIdsAtLocation(locationId) — the entity ids at a location.
  • GET /api/v1/locations/{locationId}/entities — who's at a location.
  • GET /api/v1/locations/{locationId}/occupied — boolean "is it occupied".

Movement (#146)

  • LocationRepository.moveEntityToLocation(entityId, targetLocationId) — a single atomic UPDATE that re-points the entity's placement (avoids the non-atomic remove-then-add the issue called out).
  • getGridIdOfLocation — supports same-grid validation.
  • PUT /api/v1/locations/{locationId}/entity/{entityId}/move — validates before moving:
    • entity is placed somewhere → else 404
    • target location exists → else 404
    • target is in the same grid as the entity's current location → else 400
    • target is unoccupied (collision) → else 409
  • New ConflictException → HTTP 409 in GlobalExceptionHandler.

Validation

Scoped out (noted for follow-up)

  • Neighbors query (GET .../neighbors) — Add collision / occupancy detection, per RFC 0001 #147 lists it as an example; deferred to keep this PR focused. Grid geometry (orthogonal adjacency from x,y) can be a small follow-up.
  • Adjacency enforcement on move — the move allows any unoccupied cell in the same grid; step-by-step adjacency is a game-policy choice left open.

Closes #146
Closes #147

Opened by Claude on behalf of Daniel Stephenson; verified with ./mvnw test (242 passing) under JDK 21.

RFC 0001 lists "validate and apply movement" and "spatial queries and
collision detection" as Viron responsibilities, but neither existed.

Occupancy / collision (#147):
- LocationRepository.getEntityIdsAtLocation — entity ids at a location.
- GET /api/v1/locations/{id}/entities — entities at a location.
- GET /api/v1/locations/{id}/occupied — whether a location is occupied.

Movement (#146):
- LocationRepository.moveEntityToLocation — a single atomic UPDATE that
  re-points an entity's placement (no remove-then-add window).
- getGridIdOfLocation — supports same-grid validation.
- PUT /api/v1/locations/{locationId}/entity/{entityId}/move — validates the
  entity is placed (404), the target exists (404) and is in the same grid
  (400), and the target is unoccupied (409 collision) before moving.
- New ConflictException -> HTTP 409 in GlobalExceptionHandler.

Tests: 9 new controller tests + 5 new repository tests covering each path.
Full suite: 242 passing under JDK 21 (./mvnw test).

Closes #146
Closes #147

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dmccoystephenson dmccoystephenson merged commit f56a752 into main Jun 14, 2026
1 check passed
@dmccoystephenson dmccoystephenson deleted the feat/146-147-movement-collision branch June 14, 2026 03:44
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.

Add collision / occupancy detection, per RFC 0001 Add entity movement (move endpoint + validation), per RFC 0001

1 participant