7ec8744b84c1

Add clothing
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 08 Jan 2017 00:03:46 +0000
parents 2b32c135bdad
children 083f3f90f805
branches/tags (none)
files antipodes.asd data/fabrics.lisp package.lisp src/entities/clothing.lisp src/main.lisp

Changes

--- a/antipodes.asd	Sat Jan 07 21:47:23 2017 +0000
+++ b/antipodes.asd	Sun Jan 08 00:03:46 2017 +0000
@@ -30,6 +30,7 @@
                                (:file "visible")))
                  (:module "entities" :serial t
                   :components ((:file "food")
+                               (:file "clothing")
                                (:file "ruin")
                                (:file "player")))
                  (:file "flavor")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/fabrics.lisp	Sun Jan 08 00:03:46 2017 +0000
@@ -0,0 +1,64 @@
+#(
+  ("an" "acrylic")
+  ("an" "alpaca")
+  ("an" "angora")
+  ("an" "argyle")
+  ("a" "ballistic nylon")
+  ("a" "barathea")
+  ("a" "barkcloth")
+  ("a" "bizarre silk")
+  ("a" "broadcloth")
+  ("a" "burlap")
+  ("a" "calico")
+  ("a" "canvas")
+  ("a" "capilene")
+  ("a" "carbon fiber")
+  ("a" "cashmere")
+  ("a" "chambray")
+  ("a" "cheesecloth")
+  ("a" "chiffon")
+  ("a" "cordura")
+  ("a" "corduroy")
+  ("a" "cotton")
+  ("a" "damask")
+  ("a" "denim")
+  ("a" "donegal tweed")
+  ("a" "felt")
+  ("a" "fishnet")
+  ("a" "flannel")
+  ("a" "gingham")
+  ("a" "gore-tex")
+  ("a" "grenadine")
+  ("a" "harris tweed")
+  ("a" "hemp")
+  ("a" "herringbone")
+  ("a" "houndstooth")
+  ("a" "kevlar")
+  ("a" "lace")
+  ("a" "linen")
+  ("a" "mesh")
+  ("a" "microfiber")
+  ("a" "mohair")
+  ("a" "nylon")
+  ("an" "oilskin")
+  ("a" "paisley")
+  ("a" "polar fleece")
+  ("a" "polyester")
+  ("a" "rayon")
+  ("a" "ripstop")
+  ("a" "sateen")
+  ("a" "satin")
+  ("a" "sea silk")
+  ("a" "silk")
+  ("a" "spandex")
+  ("a" "spider silk")
+  ("a" "terrycloth")
+  ("a" "tweed")
+  ("a" "twill")
+  ("a" "velour")
+  ("a" "velvet")
+  ("a" "velveteen")
+  ("a" "ventile")
+  ("a" "wool")
+
+  )
--- a/package.lisp	Sat Jan 07 21:47:23 2017 +0000
+++ b/package.lisp	Sun Jan 08 00:03:46 2017 +0000
@@ -57,6 +57,9 @@
     :make-food
     :food/energy
 
+    :clothing
+    :make-clothing
+
     :trigger
     :trigger?
     :trigger/text
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/entities/clothing.lisp	Sun Jan 08 00:03:46 2017 +0000
@@ -0,0 +1,54 @@
+(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::+yellow-black+
+    :holdable/description (random-clothing-description)))
+
--- a/src/main.lisp	Sat Jan 07 21:47:23 2017 +0000
+++ b/src/main.lisp	Sun Jan 08 00:03:46 2017 +0000
@@ -110,11 +110,22 @@
                           (not (eq :wall (aref *structures* x y)))))
              (setf (aref *structures* x y) nil))))
 
+(defun random-ruin-floor-space (width height start-x start-y)
+  (values (random-range (1+ start-x) (+ start-x width -1))
+          (random-range (1+ start-y) (+ start-y height -1))))
+
 (defun place-ruin-food (width height start-x start-y)
-  (iterate (repeat (random 4))
-           (make-food
-             (random-range (1+ start-x) (+ start-x width))
-             (random-range (1+ start-y) (+ start-y height)))))
+  (iterate
+    (repeat (random 4))
+    (multiple-value-call #'make-food
+      (random-ruin-floor-space width height start-x start-y))))
+
+(defun place-ruin-clothing (width height start-x start-y)
+  (when (randomp)
+    (iterate
+      (repeat (random-range 1 4))
+      (multiple-value-call #'make-clothing
+        (random-ruin-floor-space width height start-x start-y)))))
 
 (defun add-ruin-trigger (width height start-x start-y)
   (make-ruin (+ start-x (truncate width 2))
@@ -130,6 +141,7 @@
     (add-ruin-door width height x y)
     (decay-ruin width height x y condition)
     (place-ruin-food width height x y)
+    (place-ruin-clothing width height x y)
     (add-ruin-trigger width height x y)))
 
 (defun fill-ruins ()
@@ -204,7 +216,9 @@
         *view-x* 0 *view-y* 0))
 
 (defun spawn-player ()
-  (setf *player* (make-player)))
+  (setf *player* (make-player))
+  (iterate (repeat 2)
+           (player-get *player* (make-clothing 0 0))))
 
 (defun place-food ()
   (iterate
@@ -377,7 +391,9 @@
 
 (defun get-items ()
   (iterate (for item :in (remove-if-not #'holdable? (coords-nearby *player* 0)))
-           (until (player-inventory-full-p *player*))
+           (when (player-inventory-full-p *player*)
+             (popup "You can't carry any more items.")
+             (return))
            (player-get *player* item)))