| Paste number 79190: | untitled |
| Pasted by: | JAS415 |
| When: | 1 year, 4 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1P3Q |
| Channel: | #lisp |
| Paste contents: |
(defun directionp (a)
(or (eq a :north)
(eq a :south)
(eq a :east)
(eq a :west)
(eq a :up)
(eq a :down)))
(deftype direction ()
'(and keyword (satisfies directionp)))
(defgeneric look (object location)
(:method ((location location) (item item))
(dolist (item (items location))
(when (string-equal string (name item))
(return (format nil "You look at ~a~%It looks like:~%~a" (name item) (desc item))))))
(:method ((location location) (keyword direction))
(macrolet
((dir (dir)
(let ((a (gensym)))
`(let ((,a (,dir *current-room*)))
(if ,a
(format nil "You gaze into the distance at ~a, to the ~a: ~%~%~a"
(name ,a)
(string-downcase (format nil "~a" direction))
(or (short-desc ,a)
(desc ,a)))
"There's nothing to see there")))))
(case direction
(:UP (dir up))
(:DOWN (dir down))
(:NORTH (dir north))
(:SOUTH (dir south))
(:EAST (dir east))
(:WEST (dir west))
(t (format nil "You look around yourself, you see:~%~a~% ~a" (name *current-room*) (desc *current-room*)))
))))
This paste has no annotations.