Skip to content

Add 'gravestone' feature #337

@dmccoystephenson

Description

@dmccoystephenson

Summary

When the player dies, spawn a Gravestone entity at their location containing all dropped items. The player can right-click it to retrieve everything at once. Implement item storage on the entity in a way that can be reused by chests in the future.

Background

Currently checkForLivingEntityDeaths() in worldScreen.py drops the player's inventory items directly onto the ground as individual entities. Retrieving them after respawning requires picking up each item one by one. A gravestone that holds the items as a collection would be much less tedious and naturally leads toward a reusable storage interface needed for chests (see #346).

Requirements

Shared Storage Interface

  • Create a StorableInventory mixin or base class (e.g. src/entity/storableEntity.py) that holds an Inventory instance and exposes getStoredInventory() — this same interface should be used by the future Chest entity

Gravestone Entity

  • Add Gravestone (src/entity/gravestone.py) — solid, not craftable, not directly pickupable, with a placeholder asset (assets/images/gravestone.png)
  • Gravestone uses StorableInventory to hold the player's dropped items

On Player Death

  • In worldScreen.py checkForLivingEntityDeaths(), instead of scattering individual items into the room, create a Gravestone, transfer the full player inventory into its stored inventory, and place it at the player's last known location

Interaction

  • Right-clicking a Gravestone in the world transfers all stored items into the player's inventory (using placeIntoFirstAvailableInventorySlot) and removes the Gravestone from the room
  • If the player's inventory is full, set a status message via status.set("Inventory full") and leave the gravestone in place

Persistence

  • Extend RoomJsonReaderWriter (src/world/roomJsonReaderWriter.py) to serialize/deserialize Gravestone entities including their stored inventory contents
  • Follow the existing entity registry pattern in roomJsonReaderWriter.py and inventoryJsonReaderWriter.py

Pickup / Placement Guards

  • Gravestone should not appear in canBePickedUp() in worldScreen.py
  • Gravestone should not appear in the crafting registry

Acceptance Criteria

  • On player death, a Gravestone is spawned at the player's location containing all dropped items
  • Individual items are no longer scattered on the ground on death
  • Right-clicking the gravestone returns all items to the player's inventory
  • If the player's inventory is full, the gravestone is left in place with a status message
  • Gravestone contents survive save/load cycles
  • StorableInventory is decoupled enough to be reused by the future Chest entity (Add storage containers #346)
  • All existing tests pass; new tests cover gravestone spawning on death, item retrieval, full-inventory guard, and save/load round-trip

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions