7498a056c40c

Add points
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 08 Jan 2017 13:29:01 +0000
parents 9aad3f5f030b
children 42e7e264ebdd
branches/tags (none)
files antipodes.asd package.lisp src/aspects/worth.lisp src/entities/clothing.lisp src/entities/jewelery.lisp src/main.lisp

Changes

--- a/antipodes.asd	Sun Jan 08 13:19:27 2017 +0000
+++ b/antipodes.asd	Sun Jan 08 13:29:01 2017 +0000
@@ -27,6 +27,7 @@
                   :components ((:file "coordinates")
                                (:file "holdable")
                                (:file "trigger")
+                               (:file "worth")
                                (:file "visible")))
                  (:module "entities" :serial t
                   :components ((:file "food")
--- a/package.lisp	Sun Jan 08 13:19:27 2017 +0000
+++ b/package.lisp	Sun Jan 08 13:29:01 2017 +0000
@@ -81,6 +81,10 @@
     :coords-nearby
     :coords-move-entity
 
+    :worth
+    :worth?
+    :worth/points
+
     :holdable
     :holdable?
     :holdable/description
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/aspects/worth.lisp	Sun Jan 08 13:29:01 2017 +0000
@@ -0,0 +1,3 @@
+(in-package :ap.entities)
+
+(define-aspect worth points)
--- a/src/entities/clothing.lisp	Sun Jan 08 13:19:27 2017 +0000
+++ b/src/entities/clothing.lisp	Sun Jan 08 13:29:01 2017 +0000
@@ -30,7 +30,7 @@
     "boxers"
     "panties"))
 
-(define-entity clothing (visible coords holdable))
+(define-entity clothing (visible coords holdable worth))
 
 (defun random-clothing-description ()
   (destructuring-bind (article fabric)
@@ -50,5 +50,6 @@
     :coords/y y
     :visible/glyph "&"
     :visible/color ap::+black-white+
+    :worth/points (random-range 100 200)
     :holdable/description (random-clothing-description)))
 
--- a/src/entities/jewelery.lisp	Sun Jan 08 13:19:27 2017 +0000
+++ b/src/entities/jewelery.lisp	Sun Jan 08 13:29:01 2017 +0000
@@ -17,7 +17,7 @@
     "locket"
     "medallion"))
 
-(define-entity jewelery (visible coords holdable))
+(define-entity jewelery (visible coords holdable worth))
 
 (defun random-jewelery-description ()
   (destructuring-bind (article gem)
@@ -30,4 +30,5 @@
     :coords/y y
     :visible/glyph "*"
     :visible/color ap::+black-pink+
+    :worth/points (random-range 100 1000)
     :holdable/description (random-jewelery-description)))
--- a/src/main.lisp	Sun Jan 08 13:19:27 2017 +0000
+++ b/src/main.lisp	Sun Jan 08 13:29:01 2017 +0000
@@ -272,6 +272,15 @@
         (iterate (until (eql #\space (charms:get-char win)))))))
   nil)
 
+(defun show-possessions ()
+  (when (not (player-inventory-empty-p *player*))
+    (let ((items (remove-if-not #'worth? (player/inventory *player*))))
+      (popup (format nil "Your possessions were worth ~D points.~2%~{~D - ~A~%~}"
+                     (reduce #'+ items :key #'worth/points)
+                     (-<> items
+                       (mapcar (juxt #'worth/points #'holdable/description) <>)
+                       (apply #'append <>)))))))
+
 
 ;;;; Selection Menu -----------------------------------------------------------
 (defun key->index (key)
@@ -317,12 +326,14 @@
 ;;;; Death --------------------------------------------------------------------
 (defun death ()
   (popup *death*)
+  (show-possessions)
   (popup "Thanks for playing!"))
 
 
 ;;;; Winning ------------------------------------------------------------------
 (defun win ()
   (popup *win*)
+  (show-possessions)
   (popup "Thanks for playing!"))