X-Git-Url: https://jxself.org/git/?p=mudsync.git;a=blobdiff_plain;f=mudsync%2Fplayer.scm;h=00b28edde4cbeab67239e2266dd462d06469c9d6;hp=bf19a16a6b0e1a0a4716f70333cddaec2a757b8e;hb=d539213774955a5593ec760f06022aeecf4e1abc;hpb=7525c62ccdf9e3480214831fb14d9a2d30ab139d diff --git a/mudsync/player.scm b/mudsync/player.scm index bf19a16..00b28ed 100644 --- a/mudsync/player.scm +++ b/mudsync/player.scm @@ -37,11 +37,9 @@ (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)) - ;; @@: We really need to unify / make sensible this look stuff - (look-room (wrap-apply player-look-room)))) + (tell (wrap-apply player-tell)))) (define player-actions* (append player-actions @@ -68,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) @@ -95,26 +94,6 @@ (<- player (gameobj-gm player) 'write-home #:text text)) -(define-mhandler (player-look-room player message) - (player-look-around player)) - - -;;; 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 ;;; ================ @@ -156,14 +135,20 @@ (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 @@ -188,8 +173,10 @@ (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)