2024-05-24 00:19:00 +00:00
|
|
|
#lang racket/gui
|
|
|
|
(require "structs.rkt"
|
|
|
|
"utils.rkt")
|
|
|
|
|
|
|
|
(provide look)
|
|
|
|
|
|
|
|
(define (look what where)
|
|
|
|
(if (empty? what)
|
2024-05-26 00:42:15 +00:00
|
|
|
(~a "In this area, there is: " (oxford-list (object-names where)))
|
2024-05-24 00:19:00 +00:00
|
|
|
(let* ([what-str (string-join what)]
|
|
|
|
[obj (find-object-by-name what-str where)])
|
|
|
|
(if obj
|
|
|
|
(~a "There is a " what-str " in the area."
|
|
|
|
(describe-obj obj))
|
|
|
|
(~a "The \"" what-str "\" you're looking for isn't in this area.")))))
|
|
|
|
|
|
|
|
(define (describe-obj obj)
|
|
|
|
(let ([output ""])
|
|
|
|
(when (player? obj)
|
|
|
|
(append-str! output "\nIt's you."))
|
|
|
|
|
|
|
|
(when (item? obj)
|
|
|
|
(append-str! output (~a "\nIt has a size of: " (item-size obj) "."))
|
|
|
|
(when (equipment? obj)
|
|
|
|
(append-str! output (~a "\nIt is a piece of equipment of type: " (equipment-type obj) "."))
|
|
|
|
(when (weapon? obj)
|
|
|
|
(append-str! output (~a "\nIt deals " (weapon-damage obj) " damage.")))
|
|
|
|
(when (armor? obj)
|
|
|
|
(append-str! output (~a "\nIt has a damage resistance of: " (armor-resistance obj) ".")))))
|
|
|
|
|
|
|
|
(cond
|
|
|
|
[(creature? obj)
|
|
|
|
(append-str! output (~a "\nIts species is: " (creature-species obj) "."))
|
|
|
|
(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."))
|
2024-05-26 00:42:15 +00:00
|
|
|
(append-str! output (~a "\nIt looks like it's carrying: " (oxford-list (equipment-types obj)))))]
|
2024-05-24 00:19:00 +00:00
|
|
|
[else
|
|
|
|
(when (entity? obj)
|
2024-05-26 00:42:15 +00:00
|
|
|
(append-str! output (~a "\nInside is: " (oxford-list (object-names obj)))))]
|
2024-05-24 00:19:00 +00:00
|
|
|
)
|
|
|
|
output))
|