Can FINALLY interact with objects! Woohoo!
[mudsync.git] / mudsync / player.scm
index 3aa22873a257155d994c5aced4310f12738e3060..00b28edde4cbeab67239e2266dd462d06469c9d6 100644 (file)
@@ -37,7 +37,7 @@
 
 (define player-actions
   (build-actions
-   (init (wrap-apply player-init!))
+   (init (wrap-apply player-init))
    (handle-input (wrap-apply player-handle-input))
    (tell (wrap-apply player-tell))))
 
@@ -66,8 +66,9 @@
 
 ;;; player message handlers
 
-(define-mhandler (player-init! player message)
-  (player-look-around player))
+(define-mhandler (player-init player message)
+  ;; Look around the room we're in
+  (<- player (gameobj-loc player) 'look-room))
 
 
 (define-mhandler (player-handle-input player message input)
       #:text text))
 
 
-;;; player methods
-
-(define (player-look-around player)
-  (define room-name
-    (message-ref
-     (<-wait player (gameobj-loc player) 'get-name)
-     'val))
-  (define room-desc
-    (message-ref
-     (<-wait player (gameobj-loc player) 'get-desc)
-     'val))
-  (define message-text
-    (format #f "**~a**\n~a\n" room-name room-desc))
-
-  (<- player (gameobj-gm player) 'write-home #:text message-text))
-
-
 ;;; Command handling
 ;;; ================
 
   (define co-occupant-commands
     ;; TODO: Switch this to a fold.  Ignore a result if it
     ;;   returns false for in the command response
-    (map
-     (lambda (co-occupant)
-       (let ((result (<-wait player co-occupant 'get-commands
-                             #:verb verb)))
-         (list
-          (message-ref result 'commands)
-          (message-ref result 'goes-by)
-          co-occupant)))
+    (fold
+     (lambda (co-occupant prev)
+       (display "pre-message\n")
+       (let* ((result (<-wait player co-occupant 'get-commands
+                              #:verb verb))
+              (commands (message-ref result 'commands))
+              (goes-by (message-ref result 'goes-by)))
+         (display "post-message\n")
+         (append
+          (map (lambda (command)
+                 (list command goes-by co-occupant))
+               commands)
+          prev)))
+     '()
      co-occupants))
 
   ;; Append our own command handlers
   (sort
    actors-and-commands
    (lambda (x y)
-     (> (command-priority (car (pk 'x x)))
-        (command-priority (car (pk 'y y)))))))
+     (pk 'x x)
+     (pk 'y y)
+     (> (command-priority (car x))
+        (command-priority (car y))))))
 
 
 (define (find-command-winner sorted-candidates line)