X-Git-Url: https://jxself.org/git/?p=mudsync.git;a=blobdiff_plain;f=mudsync%2Froom.scm;h=efb52d828e96efeda3c5d12e3ace6262f5f22b40;hp=2c19788034c3485245553e84278ac13490ac7efa;hb=701425bc611abaa8b4140942d995d5f32d24e2d7;hpb=6cff5b0062ef928204295ab4327bf2d417070421 diff --git a/mudsync/room.scm b/mudsync/room.scm index 2c19788..efb52d8 100644 --- a/mudsync/room.scm +++ b/mudsync/room.scm @@ -19,16 +19,12 @@ (define-module (mudsync room) #:use-module (mudsync command) #:use-module (mudsync gameobj) - #:use-module (8sync systems actors) + #:use-module (8sync actors) #:use-module (8sync agenda) #:use-module (oop goops) #:use-module (srfi srfi-1) #:use-module (ice-9 control) - #:export ( - room-actions - room-actions* - - )) + #:export ( )) ;;; Exits @@ -72,26 +68,6 @@ (greedy-command "say" 'cmd-say) (greedy-command "emote" 'cmd-emote))) -(define room-actions - (build-actions - (cmd-go (wrap-apply room-cmd-go)) - (cmd-go-where (wrap-apply room-cmd-go-where)) - (announce-entrance (wrap-apply room-announce-entrance)) - (look-room (wrap-apply room-look-room)) - (tell-room (wrap-apply room-act-tell-room)) - ;; in this case the command is the same version as the normal - ;; look-room version - (cmd-look-room (wrap-apply room-look-room)) - (cmd-look-at (wrap-apply room-look-at)) - (cmd-say (wrap-apply room-cmd-say)) - (cmd-emote (wrap-apply room-cmd-emote)))) - -(define room-actions* - (append room-actions gameobj-actions)) - -(define room-action-dispatch - (simple-dispatcher room-actions*)) - ;; TODO: Subclass from container? (define-class () ;; A list of @@ -102,10 +78,20 @@ (container-commands #:init-value (wrap %room-contain-commands)) - (message-handler - #:allocation #:each-subclass - ;; @@: Can remove this indirection once things settle - #:init-value (wrap-apply room-action-dispatch))) + (actions #:allocation #:each-subclass + #:init-value + (build-actions + (cmd-go room-cmd-go) + (cmd-go-where room-cmd-go-where) + (announce-entrance room-announce-entrance) + (look-room room-look-room) + (tell-room room-act-tell-room) + ;; in this case the command is the same version as the normal + ;; look-room version + (cmd-look-room room-look-room) + (cmd-look-at room-look-at) + (cmd-say room-cmd-say) + (cmd-emote room-cmd-emote)))) (define* (room-cmd-go room message #:key direct-obj) (define exit @@ -119,9 +105,7 @@ (dyn-ref room (slot-ref exit 'to)) #f)) (define player-name - (msg-receive (_ #:key val) - (<-wait room (message-from message) 'get-name) - val)) + (msg-val (<-wait room (message-from message) 'get-name))) (cond (exit ;; Set the player's new location @@ -237,10 +221,8 @@ (cond (matching-object (let ((obj-desc - (msg-receive (_ #:key val) - (<-wait room matching-object 'get-desc - #:whos-looking (message-from message)) - val))) + (msg-val (<-wait room matching-object 'get-desc + #:whos-looking (message-from message))))) (if obj-desc (<- room (message-from message) 'tell #:text (string-append obj-desc "\n")) @@ -273,10 +255,8 @@ (define* (room-cmd-say room message #:key phrase) "Command: Say something to room participants." (define player-name - (msg-receive (_ #:key val) - (<-wait room (message-from message) - 'get-name) - val)) + (msg-val (<-wait room (message-from message) + 'get-name))) (define message-to-send (format #f "~a says: ~a\n" player-name phrase)) (room-tell-room room message-to-send)) @@ -284,19 +264,15 @@ (define* (room-cmd-emote room message #:key phrase) "Command: Say something to room participants." (define player-name - (msg-receive (_ #:key val) - (<-wait room (message-from message) - 'get-name) - val)) + (msg-val (<-wait room (message-from message) + 'get-name))) (define message-to-send (format #f "* ~a ~a\n" player-name phrase)) (room-tell-room room message-to-send)) (define* (room-announce-entrance room message #:key who-entered) (define player-name - (msg-receive (_ #:key val) - (<-wait room who-entered 'get-name) - val)) + (msg-val (<-wait room who-entered 'get-name))) (define message-to-send (format #f "~a enters the room.\n" player-name)) (room-tell-room room message-to-send