Functional Zork
In this game, there is a single character that moves around in a world. In this world, the player is able to examine the current location, move between locations, pickup objects, and drop objects. The list of commands are as follows:
Walk
: This moves from one location to anotherLook
: This views the current locationPickup
: This picks up an objectDrop
: This drops an objectInventory
: This sees what the player is holdingDirections
: This determines the possible directions from the current location
Most commands have synonyms to make it easy to enter commands. These will be detailed as they occur and are quite easy to add or remove. A variation of the command pattern as developed in Chapter 7, Supporting Design Patterns Using Functional Programming is incorporated. As we will see, a Map
class and lambda expressions are used to eliminate the need for individual command classes.
The world is made up of a series of locations. Each location has a name, a description, can hold items...