Describing It All

Now we’ll tie all of these description functions into one easy command called look. Because this will be the actual command players can enter to look around them in the game, look will need to know a player’s current location. So, we need a variable to track the player’s current position. Let’s call it *location*:

(defparameter *location* 'living-room)

Because the *location* value is initialized to the living-room symbol, which occurs at the very start of the game, players will find themselves in the living room of the wizard’s house. At this point, we can write a look function to describe everything we need by having it call all of our descriptor functions:

(defun look () (append (describe-location *location* *nodes*) (describe-paths ...

Get Land of Lisp now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.