Add container support for items #506

Merged
scion merged 10 commits from containers into master 2026-05-31 01:40:53 -07:00
Owner

Containers are MudItems that can hold other MudItems, similar to
character inventories. Key changes:

Model:

  • ItemComponent: added isContainer boolean field (defaults false)
  • LocationComponent: added container field (ManyToOne MudItem)
  • MudItemRepository: added findByLocationContainer query method

Commands:

  • PUT : puts a held item into a held container
  • GET : retrieves an item from a held container
  • LOOK : shows contents of a held container
  • GET (existing ground syntax unchanged)
  • OPEN : open a container
  • CLOSE : close a container
  • LOCK : lock a lockable container
  • UNLOCK : unlock a lockable container, if you are also holding its key

All new container code is fully tested with no surviving mutations
outside the benign Spring constructor addSyntax pattern.

Containers are MudItems that can hold other MudItems, similar to character inventories. Key changes: Model: - ItemComponent: added isContainer boolean field (defaults false) - LocationComponent: added container field (ManyToOne MudItem) - MudItemRepository: added findByLocationContainer query method Commands: - PUT <item> <container>: puts a held item into a held container - GET <item> <container>: retrieves an item from a held container - LOOK <container>: shows contents of a held container - GET (existing ground syntax unchanged) - OPEN <item> : open a container - CLOSE <item> : close a container - LOCK <item> : lock a lockable container - UNLOCK <item> : unlock a lockable container, if you are also holding its key All new container code is fully tested with no surviving mutations outside the benign Spring constructor addSyntax pattern.
Add container support for items
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 10m53s
31a805b596
Containers are MudItems that can hold other MudItems, similar to
character inventories.  Key changes:

Model:
- ItemComponent: added isContainer boolean field (defaults false)
- LocationComponent: added container field (ManyToOne MudItem)
- MudItemRepository: added findByLocationContainer query method

Commands:
- PUT <item> <container>: puts a held item into a held container
- GET <item> <container>: retrieves an item from a held container
- LOOK <container>: shows contents of a held container
- GET (existing ground syntax unchanged)

All new container code is fully tested with no surviving mutations
outside the benign Spring constructor addSyntax pattern.
scion self-assigned this 2026-05-29 00:54:03 -07:00
Enforce isContainer check in Put, Get, and Look commands
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 11m9s
df6a1b024a
- PutCommand: Rejects putting items into non-container targets with
  '<item> is not a container.' message
- GetCommand: Rejects getting items from non-container sources (FROM path)
  with same error message
- LookCommand: Rejects looking inside non-container items with same error
- Added corresponding tests for non-container rejection in all three commands
- Updated existing tests to explicitly mock isContainer as true for valid
  containers

All mutations for the new guard clauses are killed per Pitest verification.
Add isContainer toggle to item editor and copy it during buildInstance
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 11m30s
2e84a857d6
- MudItemTemplate.buildInstance() now copies isContainer from the template
  to the built item instance
- ItemEditorQuestion menu now shows 'Container: true/false' option (C)
  that toggles the isContainer flag on the item prototype
- Added tests for isContainer being copied in buildInstance (both true
  and default false cases)
- Added tests for the editor menu showing isContainer value and the
  toggle working in both directions
Add OPEN/CLOSE commands and closed container checks
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 11m38s
106246f27e
- Added canOpen and isOpen boolean fields to ItemComponent with
  getters/setters; both default to false
- Updated MudItemTemplate.buildInstance() to copy canOpen and isOpen
  from template to built instance
- Added 'O' (Openable) toggle to ItemEditorQuestion menu; toggles
  canOpen on the item prototype
- Created OpenCommand: opens a held or ground item; rejects items that
  cannot be opened or are already open
- Created CloseCommand: closes a held or ground item; rejects items that
  cannot be closed or are already closed
- Updated LookCommand: closed containers (canOpen && !isOpen) now show
  '<item> is closed.' instead of listing contents
- Added comprehensive tests for all new functionality
Add Lock/Unlock commands and item locking functionality
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 11m54s
74d40102f8
- Add LockCommand and UnlockCommand for locking/unlocking items
- Update OpenCommand to check lock status before opening
- Add locked field to ItemComponent and MudItemTemplate
- Update LookCommand to display lock status
- Update ItemEditorQuestion for locked item editing
- Add corresponding unit tests
Merge branch 'master' into containers
Some checks failed
CI Build & Test / build-and-test (pull_request) Has been cancelled
13a9c8b18d
Update game-object-model docs for container/locking features
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 12m44s
a578916744
- Update ItemComponent description in entity hierarchy table
- Add new fields to ItemComponent schema: isContainer, canOpen, isOpen,
  keyFor, isLocked
- Add section documenting container and locking state, including the
  locking workflow and template-to-instance propagation
tweaks and bugfixes for containers
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 16m11s
faeeaf19d5
Make PURGE recursively delete container contents before deleting the container
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 12m23s
77d9322185
purgeItem now recursively deletes all items inside a container before
deleting the container itself, preventing foreign key constraint violations
on the location_component table.

purgeCharacter drops the character's held items on the ground in their
current room before deleting the character, rather than deleting them.

Added a visited-set guard in purgeItem to prevent infinite recursion if
the database somehow contains a container cycle. Added tests for:
- Nested container recursion (bag > chest > gem)
- Cycle detection (mutually containing containers)
- Character purge dropping held items on the ground
allow GET, LOOK, PUT for containers on the ground, adjust error messaging for commands
All checks were successful
CI Build & Test / build-and-test (pull_request) Successful in 12m21s
15d6fcbaf4
scion changed title from WIP: Add container support for items to Add container support for items 2026-05-31 01:40:32 -07:00
scion merged commit df3f95ebdf into master 2026-05-31 01:40:53 -07:00
scion deleted branch containers 2026-05-31 01:40:53 -07:00
Sign in to join this conversation.
No description provided.