A text adventure engine
The problem
Build a small text adventure: rooms connected by exits, items to pick up and use, and a parser for commands such as go north, take key and use key.
Requirements
- Room and Item classes, with an enum for directions
- A map of rooms and each room's exits, and a set for the player's inventory
- A command parser that reports unknown commands and impossible actions
- A win condition and a move counter
Technologies
- Java 17
- Enums
- Collections
- Interfaces
- Exceptions
Step by step
- Design the rooms, exits and items as classes and an enum.
- Build a small world in code and print the room descriptions.
- Write the command parser and each command as a method.
- Add items, locked exits, a win condition and tests of tricky commands.
Expected result
A playable adventure whose world can be extended without changing the engine.
How it is evaluated
- Every command either works or gives a clear reason
- New rooms need no engine changes
- The game state cannot become inconsistent
- The code uses enums, collections and interfaces appropriately
Ways to improve it
- Load the world from a text file
- Add an Action interface for commands
- Add saving and loading of a game