src/entities/clothing.lisp @ 0124edbf5a6f

Check bounds, tame the flavors
author Steve Losh <steve@stevelosh.com>
date Sun, 08 Jan 2017 12:11:21 +0000
parents bf74ba7cd2b7
children 7498a056c40c
(in-package :ap.entities)

(defparameter *fabrics*
  (read-file-into-form "data/fabrics.lisp"))

(defparameter *singular-clothes*
  #("coat"
    "shirt"
    "skirt"
    "dress"
    "belt"
    "tie"
    "bow tie"
    "sock"
    "bra"
    "scarf"
    "jacket"
    "vest"
    "blouse"
    "sweater"
    "dress shirt"))

(defparameter *plural-clothes*
  #("pants"
    "socks"
    "briefs"
    "gloves"
    "tights"
    "shorts"
    "boxers"
    "panties"))

(define-entity clothing (visible coords holdable))

(defun random-clothing-description ()
  (destructuring-bind (article fabric)
      (random-elt *fabrics*)
    (if (randomp)
      (format nil "~A ~A ~A"
              article
              fabric
              (random-elt *singular-clothes*))
      (format nil "a set of ~A ~A"
              fabric
              (random-elt *plural-clothes*)))))

(defun make-clothing (x y)
  (create-entity 'clothing
    :coords/x x
    :coords/y y
    :visible/glyph "&"
    :visible/color ap::+black-white+
    :holdable/description (random-clothing-description)))