X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=mudsync%2Fcommand.scm;h=95e04c5282b83d6b05a991071d62f7788340fe02;hb=055ce4c85ccf38385b80d1873927e059f7b58a20;hp=a79f50d3e7f878ae24b9a1b6d8d5d98ebaeb0086;hpb=4d4af0656b0402e630eea9393420197152945e5b;p=mudsync.git diff --git a/mudsync/command.scm b/mudsync/command.scm index a79f50d..95e04c5 100644 --- a/mudsync/command.scm +++ b/mudsync/command.scm @@ -18,6 +18,7 @@ (define-module (mudsync command) #:use-module (mudsync parser) + #:use-module (mudsync utils) #:use-module (8sync actors) #:use-module (8sync rmeta-slot) #:use-module (srfi srfi-1) @@ -64,13 +65,14 @@ ;; (define command-priority sixth) (define-record-type - (make-command verbs matcher should-handle action priority) + (make-command verbs matcher should-handle action priority obvious?) command? (verbs command-verbs) (matcher command-matcher) (should-handle command-should-handle) (action command-action) - (priority command-priority)) + (priority command-priority) + (obvious? command-obvious?)) (define-syntax %build-command (syntax-rules () @@ -89,87 +91,102 @@ ...)))))) (define-syntax-rule (build-commands (verb-or-verbs cmd-defs ...) ...) - (wrap-rmeta-slot + (build-rmeta-slot (append (%build-command verb-or-verbs cmd-defs ...) ...))) -(define (direct-command verbs action) +(define* (direct-command verbs action #:key (obvious? #t)) (make-command verbs cmatch-direct-obj ;; @@: Should we allow fancier matching than this? ;; Let the actor itself pass along this whole method? (lambda* (goes-by #:key direct-obj) - (member direct-obj goes-by)) + (ci-member direct-obj goes-by)) action - %default-priority)) + %default-priority + obvious?)) -(define (loose-direct-command verbs action) +(define* (loose-direct-command verbs action #:key (obvious? #t)) (make-command verbs cmatch-direct-obj ;; @@: Should we allow fancier matching than this? ;; Let the actor itself pass along this whole method? (const #t) action - %default-priority)) + %default-priority + obvious?)) -(define* (prep-indir-command verbs action #:optional prepositions) +(define* (prep-indir-command verbs action #:optional prepositions + #:key (obvious? #t)) (make-command verbs cmatch-indir-obj (lambda* (goes-by #:key direct-obj indir-obj preposition) (if prepositions (and - (member indir-obj goes-by) - (member preposition prepositions)) - (member indir-obj goes-by))) + (ci-member indir-obj goes-by) + (ci-member preposition prepositions)) + (ci-member indir-obj goes-by))) action - %high-priority)) + %high-priority + obvious?)) -(define* (prep-direct-command verbs action #:optional prepositions) +(define* (prep-direct-command verbs action #:optional prepositions + #:key (obvious? #t)) (make-command verbs cmatch-indir-obj (lambda* (goes-by #:key direct-obj indir-obj preposition) (if prepositions (and - (member direct-obj goes-by) - (member preposition prepositions)) - (member direct-obj goes-by))) + (ci-member direct-obj goes-by) + (ci-member preposition prepositions)) + (ci-member direct-obj goes-by))) action - %high-priority)) + %high-priority + obvious?)) -(define* (loose-prep-command verbs action #:optional prepositions) +(define* (loose-prep-command verbs action #:optional prepositions + #:key (obvious? #t)) (make-command verbs cmatch-indir-obj (const #t) action - %high-priority)) + %high-priority + obvious?)) -(define (empty-command verbs action) +(define* (empty-command verbs action + #:key (obvious? #t)) (make-command verbs cmatch-empty (const #t) action - %low-priority)) + %low-priority + obvious?)) -(define (greedy-command verbs action) +(define* (greedy-command verbs action + #:key (obvious? #t)) (make-command verbs cmatch-greedy (const #t) action - %low-priority)) + %low-priority + obvious?)) -(define (direct-greedy-command verbs action) +(define* (direct-greedy-command verbs action + #:key (obvious? #t)) "greedy commands but which match the direct object" (make-command verbs cmatch-direct-obj-greedy (lambda* (goes-by #:key direct-obj rest) - (member direct-obj goes-by)) + (ci-member direct-obj goes-by)) action - %low-priority)) + %low-priority + obvious?)) ;; @@: We should probably ONLY allow these to go to users! (define* (custom-command verbs matcher should-handle action - #:optional (priority %default-priority)) + #:optional (priority %default-priority) + #:key (obvious? #t)) "Full-grained customizable command." - (make-command verbs matcher should-handle action priority)) + (make-command verbs matcher should-handle action priority obvious?))