+ #:init-value (wrap %room-contain-commands))
+
+ (actions #:allocation #:each-subclass
+ #:init-value
+ (build-actions
+ (cmd-go room-cmd-go)
+ (cmd-go-where room-cmd-go-where)
+ (announce-entrance room-announce-entrance)
+ (look-room room-look-room)
+ (tell-room room-act-tell-room)
+ ;; in this case the command is the same version as the normal
+ ;; look-room version
+ (cmd-look-room room-look-room)
+ (cmd-look-at room-look-at)
+ (cmd-say room-cmd-say)
+ (cmd-emote room-cmd-emote))))
+
+(define* (room-cmd-go room message #:key direct-obj)
+ (define exit
+ (find
+ (lambda (exit)
+ (equal? (exit-name exit) direct-obj))
+ (room-exits room)))
+ (define to-address (if exit
+ ;; Get the exit, but resolve it dynamically
+ ;; in case it's a special
+ (dyn-ref room (slot-ref exit 'to))
+ #f))
+ (define player-name
+ (mbody-val (<-wait (message-from message) 'get-name)))
+ (cond
+ (exit
+ ;; Set the player's new location
+ (<-wait (message-from message) 'set-loc!
+ #:loc to-address)
+ ;; Tell everyone else the person walked away
+ (room-tell-room
+ room
+ (format #f "~a wanders ~a.\n"
+ player-name direct-obj))
+ (<- to-address 'announce-entrance
+ #:who-entered (message-from message))
+ ;; Have the new room update the player to the new location
+ (<- to-address 'look-room
+ #:to-id (message-from message)))
+ (else
+ (<- (message-from message) 'tell
+ #:text "You don't see any way to go there.\n"))))
+
+(define (room-cmd-go-where room message)
+ (<- (message-from message) 'tell
+ #:text "Go where?\n"))
+
+;;; look commands
+
+(define (list-words-as-string words)
+ "A little utility for listing a bunch of words in an English-style list"
+ ;; TODO: This could be made faster by traversing the O(n)
+ ;; list once, not twice
+ (let ((word-length (length words)))
+ (cond
+ ((eqv? word-length 0) "")
+ ((eqv? word-length 1) (car words))
+ (else
+ ;; TODO: and this is NOT efficient
+ (string-append
+ (string-join
+ (drop-right words 1)
+ ", ")
+ " and "
+ (last words))))))