diff --git a/interpret.rkt b/interpret.rkt new file mode 100644 index 0000000..3a83d3b --- /dev/null +++ b/interpret.rkt @@ -0,0 +1,13 @@ +#lang racket/gui +(provide interpret) + +; expects all strings to be uppercase +(define (interpret command) + (if (or (string=? command "TYPE HERE...") (string=? command "")) + "You need to type something in the box." + (let* ([tokens (string-split command)] + [verb (first tokens)] + [args (rest tokens)]) + (case verb + [else (~a "I don't understand the verb " verb)])))) + diff --git a/main.rkt b/main.rkt index a150a52..dad7d7b 100644 --- a/main.rkt +++ b/main.rkt @@ -9,14 +9,17 @@ #lang racket/gui (require racket/gui/easy racket/gui/easy/operator) +(require "interpret.rkt") (define mono (send the-font-list find-or-create-font 12 'modern 'normal 'normal)) -(define/obs @log "Test field\n") +(define/obs @log "You awake in a dark room.\n") (define/obs @input "Type here...") (define (text-entered event content) (when (eqv? event 'return) - (:= @log (~a (obs-peek @log) content "\n")))) + (:= @input "") + (let ([input (string-upcase content)]) + (:= @log (~a (obs-peek @log) "> " input "\n" (interpret input) "\n"))))) (render (window diff --git a/structs.rkt b/structs.rkt new file mode 100644 index 0000000..9bbca62 --- /dev/null +++ b/structs.rkt @@ -0,0 +1,10 @@ +#lang racket/gui +(provide (all-defined-out)) + +(struct item (name size)) +(struct equipment item (type)) +(struct weapon equipment (damage)) +(struct armor equipment (resistance)) + +(struct entity (name species equipment inventory)) +