diff --git a/interpret.rkt b/interpret.rkt index 9295276..dc58706 100644 --- a/interpret.rkt +++ b/interpret.rkt @@ -7,15 +7,18 @@ ;temporary hard-coded player and room with items for testing, before implementing procgen (define room1 (room "A DARK ROOM" - (pos 0 0) - (list (armor "LEATHER CAP" (pos 5 9) 1 'helmet 2)) + (list (armor "LEATHER CAP" 1 "helmet" 2) + (entity "CHEST" + (list (weapon "BIG SWORD" 4 "sword" 5))) + (creature "STINKY RAT" + (list (item "RAT FLESH" 1)) + 'rat + 6 + (list (weapon "YELLOW TOOTH" 1 "invis" 2) + (weapon "SHARP CLAW" 1 "invis" 4)))) (dim 0 0))) -(add-to-inventory! room1 (entity "CHEST" - room1 - (list (weapon "BIG SWORD" (pos 5 5) 4 'sword 5)))) (define plyr (player "YOU" - room1 '() 'human 20 '() 50)) (add-to-inventory! room1 plyr) @@ -28,6 +31,6 @@ [verb (first tokens)] [args (rest tokens)]) (case verb - [("LOOK") (look args room1)] - [("TAKE") (take args room1 plyr)] + [("LOOK" "OBSERVE") (look args room1)] + [("TAKE" "GRAB" "GIMME") (take args room1 plyr)] [else (~a "I don't understand the verb " verb ".")]))))) \ No newline at end of file diff --git a/look.rkt b/look.rkt index 9a22e9b..e9cbe8c 100644 --- a/look.rkt +++ b/look.rkt @@ -6,7 +6,7 @@ (define (look what where) (if (empty? what) - (~a "In this area, there is: " (oxford-object-names where)) + (~a "In this area, there is: " (oxford-list (object-names where))) (let* ([what-str (string-join what)] [obj (find-object-by-name what-str where)]) (if obj @@ -34,9 +34,9 @@ (append-str! output (~a "\nIt's at " (creature-health obj) "HP.")) (if (empty? (creature-equipment obj)) (append-str! output (~a "\nIt doesn't look like it's carrying anything.")) - (append-str! output (~a "\nIt looks like it's carrying something.")))] + (append-str! output (~a "\nIt looks like it's carrying: " (oxford-list (equipment-types obj)))))] [else (when (entity? obj) - (append-str! output (~a "\nInside is: " (oxford-object-names obj))))] + (append-str! output (~a "\nInside is: " (oxford-list (object-names obj)))))] ) output)) \ No newline at end of file diff --git a/main.rkt b/main.rkt index 9c3116a..7a85ced 100644 --- a/main.rkt +++ b/main.rkt @@ -24,18 +24,17 @@ (render (window #:title "Prok" - (hpanel - (vpanel - (input @log - ;hack to prevent text editing without disabling the editor - (λ (ev cnt) (let ([old (obs-peek @log)]) (:= @log "") (:= @log old))) - #:style '(multiple) - #:min-size '(600 400) - #:font mono) - (input @input - text-entered - #:enabled? #t - #:style '(single) - #:font mono)) - (vpanel - )))) \ No newline at end of file + (vpanel + (input @log + ;hack to prevent text editing without disabling the editor + (λ (ev cnt) (let ([old (obs-peek @log)]) (:= @log "") (:= @log old))) + #:style '(multiple) + #:min-size '(600 400) + #:stretch '(#t #t) + #:font mono) + (input @input + text-entered + #:enabled? #t + #:style '(single) + #:stretch '(#t #f) + #:font mono)))) \ No newline at end of file diff --git a/structs.rkt b/structs.rkt index 8547966..1e912b3 100644 --- a/structs.rkt +++ b/structs.rkt @@ -5,7 +5,7 @@ ;for clarity - an x/y pair that represents a dimension instead of a position (struct dim pos ()) -(struct object (name pos)) +(struct object (name)) (struct item object (size)) (struct equipment item (type)) diff --git a/utils.rkt b/utils.rkt index dec3ee1..30d7b88 100644 --- a/utils.rkt +++ b/utils.rkt @@ -11,16 +11,22 @@ (append (creature-equipment where) (entity-inventory where)) (entity-inventory where)))) -(define (object-names list) - (map object-name list)) +(define (object-names where) + (map object-name (entity-inventory where))) -(define (oxford-object-names where) - (let ([lst (object-names (entity-inventory where))]) - (if (empty? lst) - "nothing." - (string-join lst ", " - #:before-last ", and " - #:after-last ".")))) +(define (equipment-types creature) + (filter string? + (map (λ (e) + (unless (string=? (equipment-type e) "invis") + (equipment-type e))) + (creature-equipment creature)))) + +(define (oxford-list lst) + (if (empty? lst) + "nothing." + (string-join lst ", " + #:before-last ", and " + #:after-last "."))) (define-syntax-rule (append-str! str1 str2) (set! str1 (~a str1 str2)))