;;; along with Mudsync. If not, see <http://www.gnu.org/licenses/>.
(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 (<player>))
+ #:use-module (srfi srfi-1)
+ #:export (<player>
+ player-self-commands))
;;; Players
;;; =======
(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
(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)
(format #f "**~a**\n~a\n" room-name room-desc))
(<- player (gameobj-gm player) 'write-home #:text message-text))
+
+
+