some example room commands
[mudsync.git] / mudsync.scm
index 8cc07b1389bb5fff85619774ace295b6b8aca8a3..a15f5b9a02ea2a1f221129e2078832c9e18f3bde 100644 (file)
@@ -384,6 +384,18 @@ with an anonymous persona"
   ;; game master id
   (gm #:init-keyword #:gm
       #:getter gameobj-gm)
+  ;; a name to be known by
+  (name #:init-keyword #:name
+        #:accessor gameobj-name)
+
+  ;; how to print our name
+  (name-f #:init-keyword #:name-f
+          #:getter gameobj-name-f
+          #:init-value gameobj-simple-name-f)
+
+  ;; Name aliases
+  (aliases #:init-keyword #:aliases
+           #:init-value '())
 
   ;; Commands we can handle
   (commands #:init-value #f)
@@ -391,6 +403,11 @@ with an anonymous persona"
   (contain-commands #:init-value #f))
 
 
+(define (gameobj-simple-name-f gameobj)
+  "Simplest version: return ourselves for our name."
+  (gameobj-name gameobj))
+
+
 \f
 ;;; Rooms
 ;;; =====
@@ -435,10 +452,11 @@ with an anonymous persona"
                    #:val (slot-ref actor slot))))
 
 
+;; TODO: Subclass from container?
 (define-class <room> (<gameobj>)
-  (name #:init-keyword #:name)
   (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>
@@ -447,6 +465,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
@@ -464,6 +485,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
+   (command "look" cmatch-just-verb always 'look-room)
+   (command "look" cmatch-direct-obj always 'look-member)
+   (command "go" cmathc-just-verb always 'go-where)
+   (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."
@@ -488,6 +519,10 @@ claim to point to."
   ;; Connection id
   (client #:accessor player-client)
 
+  (self-commands
+   #:init-value #f  ; TODO: Set me to a reasonable default
+   #:accessor player-self-commands)
+
   (message-handler
    #:init-value
    (make-action-dispatch