commands finally dispatch
[mudsync.git] / mudsync / gameobj.scm
index ba0d8291b3ddcbbfcf4871ec1616ade69e94d6d1..351abe7c22a9094f0666938b73620f7669406ca9 100644 (file)
 ;;; ==========
 
 (define-module (mudsync gameobj)
+  #:use-module (mudsync command)
   #:use-module (8sync systems actors)
   #:use-module (8sync agenda)
+  #:use-module (srfi srfi-1)
   #:use-module (oop goops)
   #:export (<gameobj>
             gameobj-simple-name-f
     (reply-message actor message
                    #:val (slot-ref actor slot))))
 
+(define (filter-commands commands verb)
+  (filter
+   (lambda (cmd)
+     (equal? (command-verbs cmd)
+             verb))
+   commands))
+
 (define-mhandler (gameobj-get-commands actor message verb)
-  (<-reply actor message #:commands (slot-ref actor 'commands)))
+  (define filtered-commands
+    (filter-commands (slot-ref actor 'commands)
+                     verb))
+  (<-reply actor message #:commands filtered-commands))
 
 (define-mhandler (gameobj-get-container-commands actor message verb)
-  (<-reply actor message #:commands (slot-ref actor 'container-commands)))
+  (define filtered-commands
+    (filter-commands (slot-ref actor 'container-commands)
+                     verb))
+  (<-reply actor message #:commands filtered-commands))
 
 (define-mhandler (gameobj-add-occupant! actor message who)
   (hash-set! (slot-ref actor 'occupants)