2024-05-21 17:19:59 +00:00
|
|
|
#lang racket/gui
|
2024-05-24 00:19:00 +00:00
|
|
|
(require "structs.rkt"
|
|
|
|
"look.rkt"
|
2024-05-24 00:22:22 +00:00
|
|
|
"take.rkt"
|
2024-05-24 00:19:00 +00:00
|
|
|
"utils.rkt")
|
2024-05-21 17:19:59 +00:00
|
|
|
(provide interpret)
|
|
|
|
|
2024-05-23 19:22:05 +00:00
|
|
|
;temporary hard-coded player and room with items for testing, before implementing procgen
|
2024-05-24 00:19:00 +00:00
|
|
|
(define room1 (room "A DARK ROOM"
|
2024-05-26 00:42:15 +00:00
|
|
|
(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))))
|
2024-05-24 00:19:00 +00:00
|
|
|
(dim 0 0)))
|
|
|
|
|
|
|
|
(define plyr (player "YOU"
|
|
|
|
'()
|
|
|
|
'human 20 '() 50))
|
|
|
|
(add-to-inventory! room1 plyr)
|
2024-05-21 18:43:13 +00:00
|
|
|
|
|
|
|
(define (interpret in)
|
|
|
|
(let ([command (string-upcase in)])
|
|
|
|
(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
|
2024-05-26 00:42:15 +00:00
|
|
|
[("LOOK" "OBSERVE") (look args room1)]
|
|
|
|
[("TAKE" "GRAB" "GIMME") (take args room1 plyr)]
|
2024-05-24 00:22:22 +00:00
|
|
|
[else (~a "I don't understand the verb " verb ".")])))))
|