- Create a few more
Entity subclasses for game items. Rings, potions, cloaks, gloves, whatever fits with the flavour of your game.
- Randomly generate items lying around the dungeon. And when you create new monsters, randomly give them child entities that are the things they are carrying.
- Add a "list inventory" keypress and
Action. Create an empty div somewhere sensible, and when the player asks for their inventory, add text to that div that gives a numbered list of the player's child entities:
1. amulet
2. ring
3. sword
or You are empty-handed if the player has no child entities.
- Add a
Drop action and associated keypress. When the player hits that keypress, give them the list of their inventory, and then allow them to select which item they want to drop. Then re-parent that item to the player's level.
- When it is a monster's turn to act, if they are on a cell with an item, they can randomly choose to pick it up instead of moving.
- Similarly, a monster carrying an item can randomly choose to drop it as their action.
Entitysubclasses for game items. Rings, potions, cloaks, gloves, whatever fits with the flavour of your game.Action. Create an emptydivsomewhere sensible, and when the player asks for their inventory, add text to that div that gives a numbered list of the player's child entities:or
You are empty-handedif the player has no child entities.Dropaction and associated keypress. When the player hits that keypress, give them the list of their inventory, and then allow them to select which item they want to drop. Then re-parent that item to the player's level.