refactoring commands slots
[mudsync.git] / mudsync.scm
index 7219c37e947883daa75f9baa711b6395affc5394..35cc0befcf641f3da7b286e831656d6e98d7ed71 100644 (file)
@@ -398,7 +398,9 @@ with an anonymous persona"
            #:init-value '())
 
   ;; Commands we can handle
-  (commands #:init-value #f)
+  (dirobj-commands #:init-value '())
+  (indirobj-commands #:init-value '())
+
   ;; Commands we can handle by being something's container
   (contain-commands #:init-value #f))
 
@@ -452,9 +454,11 @@ with an anonymous persona"
                    #:val (slot-ref actor slot))))
 
 
+;; TODO: Subclass from container?
 (define-class <room> (<gameobj>)
   (desc #:init-value ""
                #:init-keyword #:desc)
+  ;; TODO: Switch this to be loc based
   ;; Uses a hash table like a set (values ignored)
   (occupants #:init-thunk make-hash-table)
   ;; A list of <exit>
@@ -463,6 +467,9 @@ with an anonymous persona"
   ;; @@: Maybe eventually <room> will inherit from some more general
   ;;  game object class
 
+  (contain-commands
+   #:init-value %room-contain-commands)
+
   (message-handler
    #:allocation #:each-subclass
    #:init-value
@@ -480,6 +487,16 @@ with an anonymous persona"
      (hash-remove! (slot-ref actor 'occupants) who))
     (wire-exits! (wrap-apply room-wire-exits!)))))
 
+(define always (const #t))
+
+(define %room-contain-commands
+  (list
+   (full-command "look" cmatch-just-verb always 'look-room)
+   (full-command "look" cmatch-direct-obj always 'look-member)
+   (full-command "go" cmathc-just-verb always 'go-where)
+   (full-command "go" cmatch-direct-obj always 'go-exit)))
+
+
 (define (room-wire-exits! room message)
   "Actually hook up the rooms' exit addresses to the rooms they
 claim to point to."
@@ -505,7 +522,7 @@ claim to point to."
   (client #:accessor player-client)
 
   (self-commands
-   #:init-value #f  ; TODO: Set me to a reasonable default
+   #:init-value '()
    #:accessor player-self-commands)
 
   (message-handler