X-Git-Url: https://jxself.org/git/?p=mudsync.git;a=blobdiff_plain;f=mudsync%2Fplayer.scm;h=fece716dbe415d45f0073dedb8e6cfa70eeaa384;hp=42359bd47db3a116391a788ed8bb39964d787ace;hb=136ce3b725c83af0b7e8be632e943de6b07b65c5;hpb=d13325f5f6eba20c808636948432dcdff4e138f6 diff --git a/mudsync/player.scm b/mudsync/player.scm index 42359bd..fece716 100644 --- a/mudsync/player.scm +++ b/mudsync/player.scm @@ -17,12 +17,17 @@ ;;; along with Mudsync. If not, see . (define-module (mudsync player) + #:use-module (mudsync command) #:use-module (mudsync gameobj) + #:use-module (mudsync game-master) + #:use-module (mudsync parser) #:use-module (8sync systems actors) #:use-module (8sync agenda) #:use-module (ice-9 format) #:use-module (oop goops) - #:export ()) + #:use-module (srfi srfi-1) + #:export ( + player-self-commands)) ;;; Players ;;; ======= @@ -39,9 +44,11 @@ (message-handler #:init-value + ;; @@: We're gonna need action inheritance real awful soon, huh? (make-action-dispatch (set-loc! (wrap-apply player-set-loc!)) - (init (wrap-apply player-init!))))) + (init (wrap-apply player-init!)) + (handle-input (wrap-apply player-handle-input))))) ;;; player message handlers @@ -53,6 +60,26 @@ (define-mhandler (player-init! player message) (player-look-around player)) + +(define-mhandler (player-handle-input player message input) + (define split-input (split-verb-and-rest input)) + (define input-verb (pk 'input-verb (car split-input))) + (define input-rest (pk 'input-rest (cdr split-input))) + + (define command-candidates + (pk 'candidates + (player-gather-command-handlers player input-verb))) + + (define winner + (pk 'winner (find-command-winner command-candidates input-rest))) + + (<- player (gameobj-gm player) 'write-home + #:text + (format #f "<~a>: ~s\n" + (player-username player) + input))) + + ;;; player methods (define (player-look-around player) @@ -68,3 +95,6 @@ (format #f "**~a**\n~a\n" room-name room-desc)) (<- player (gameobj-gm player) 'write-home #:text message-text)) + + +