adding and dropping things works
[mudsync.git] / mudsync / player.scm
index d2fc76dd64d1cbb15a4cf079bb3c9de8317761e9..172b81072b4e85e98fcf8536f91be5a9a1dccae3 100644 (file)
 
   ;; Get all the co-occupants' commands
   (define co-occupant-commands
-    ;; TODO: Switch this to a fold.  Ignore a result if it
-    ;;   returns false for in the command response
     (fold
      (lambda (co-occupant prev)
        (let* ((result (<-wait player co-occupant 'get-commands
      (val-or-run
       (slot-ref player 'self-commands))))
 
-  ;; TODO: Append our inventory's relevant command handlers
+  ;; Append our inventory's relevant command handlers
+  (define inv-items
+    (gameobj-occupants player))
+  (define inv-item-commands
+    (fold
+     (lambda (inv-item prev)
+       (let* ((result (<-wait player inv-item
+                              'get-contained-commands
+                              #:verb verb))
+              (commands (message-ref result 'commands))
+              (goes-by (message-ref result 'goes-by)))
+         (append
+          (map (lambda (command)
+                 (list command goes-by inv-item))
+               commands)
+          prev)))
+     '()
+     inv-items))
 
   ;; Now return a big ol sorted list of ((actor-id . command))
   (append
                                player-loc '()) ; room doesn't go by anything
    (sort-commands-multi-actors co-occupant-commands)
    (sort-commands-append-actor our-commands
-                               (actor-id player) '()))) ; nor does player
+                               (actor-id player) '()) ; nor does player
+   (sort-commands-multi-actors inv-item-commands)))
 
 (define (sort-commands-append-actor commands actor-id goes-by)
   (sort-commands-multi-actors