X-Git-Url: https://jxself.org/git/?p=mudsync.git;a=blobdiff_plain;f=mudsync%2Fthing.scm;h=a964c50e56aea0cc5233539ce3418d8ae6fdfa3f;hp=341371f7531dbccdd4de448b878524f5224e90da;hb=4d4af0656b0402e630eea9393420197152945e5b;hpb=7e11c67b59dc07a46576b2acaa4657ee533df7d5 diff --git a/mudsync/thing.scm b/mudsync/thing.scm index 341371f..a964c50 100644 --- a/mudsync/thing.scm +++ b/mudsync/thing.scm @@ -21,44 +21,12 @@ (define-module (mudsync thing) #: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 (ice-9 match) #:use-module (ice-9 format) - #:export ( - thing-commands - thing-contained-commands - thing-actions)) - -(define thing-commands - (list - (direct-command "take" 'cmd-take))) - -;;; Are these kinds of things useful? -;; ;; Doesn't inherit anything (gameobj has no commands) -;; ;; so it's an alias. -;; (define thing-commands* thing-commands) - -(define thing-contained-commands - (list - (empty-command "drop" 'cmd-drop))) - -;; ;; Doesn't inherit anything (gameobj has no contained-commands) -;; ;; so it's an alias. -;; (define thing-contained-commands* thing-contained-commands) - -(define thing-actions - (build-actions - (cmd-take (wrap-apply thing-cmd-take)) - (cmd-drop (wrap-apply thing-cmd-drop)))) - -(define thing-actions* - (append thing-actions - gameobj-actions)) - -(define thing-dispatcher - (simple-dispatcher thing-actions*)) + #:export ()) (define-class () ;; Can be a boolean or a procedure accepting two arguments @@ -70,19 +38,25 @@ (dropable #:init-value #t #:init-keyword #:dropable) (commands - #:init-value (wrap thing-commands)) + #:allocation #:each-subclass + #:init-thunk (build-commands + ("take" ((direct-command cmd-take))))) (contained-commands - #:init-value (wrap thing-contained-commands)) - (message-handler - #:init-value - (wrap-apply thing-dispatcher))) + #:allocation #:each-subclass + #:init-value (build-commands + ("drop" ((direct-command cmd-drop))))) + (actions #:allocation #:each-subclass + #:init-thunk + (build-actions + (cmd-take thing-cmd-take) + (cmd-drop thing-cmd-drop)))) -(define-mhandler (thing-cmd-take thing message direct-obj) +(define* (thing-cmd-take thing message #:key direct-obj) (define player (message-from message)) (define player-name - (message-ref - (<-wait thing player 'get-name) - 'val)) + (mbody-val (<-wait player 'get-name))) + (define player-loc + (mbody-val (<-wait player 'get-loc))) (define thing-name (slot-ref thing 'name)) (define should-take (slot-ref-maybe-runcheck thing 'takeable player)) @@ -90,28 +64,24 @@ ;; Set the location to whoever's picking us up (begin (gameobj-set-loc! thing player) - (<- thing player 'tell + (<- player 'tell #:text (format #f "You pick up ~a.\n" thing-name)) - (<- thing (gameobj-loc thing) 'tell-room + (<- player-loc 'tell-room #:text (format #f "~a picks up ~a.\n" player-name thing-name) #:exclude player)) - (<- thing player 'tell + (<- player 'tell #:text (format #f "It doesn't seem like you can pick up ~a.\n" thing-name)))) -(define-mhandler (thing-cmd-drop thing message direct-obj) +(define* (thing-cmd-drop thing message #:key direct-obj) (define player (message-from message)) (define player-name - (message-ref - (<-wait thing player 'get-name) - 'val)) + (mbody-val (<-wait player 'get-name))) (define player-loc - (message-ref - (<-wait thing player 'get-loc) - 'val)) + (mbody-val (<-wait player 'get-loc))) (define thing-name (slot-ref thing 'name)) (define should-drop (slot-ref-maybe-runcheck thing 'dropable player)) @@ -119,14 +89,14 @@ ;; Set the location to whoever's picking us up's location (begin (gameobj-set-loc! thing player-loc) - (<- thing player 'tell + (<- player 'tell #:text (format #f "You drop ~a.\n" thing-name)) - (<- thing player-loc 'tell-room + (<- player-loc 'tell-room #:text (format #f "~a drops ~a.\n" player-name thing-name) #:exclude player)) - (<- thing player 'tell + (<- player 'tell #:text (format #f "It doesn't seem like you can drop ~a.\n" thing-name))))