0124edbf5a6f

Check bounds, tame the flavors
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 08 Jan 2017 12:11:21 +0000
parents 8fc9b2aad98b
children 7e4af1a01d82
branches/tags (none)
files src/config.lisp src/entities/food.lisp src/entities/player.lisp src/flavor.lisp src/main.lisp

Changes

--- a/src/config.lisp	Sun Jan 08 11:56:21 2017 +0000
+++ b/src/config.lisp	Sun Jan 08 12:11:21 2017 +0000
@@ -1,7 +1,7 @@
 (in-package :ap)
 
 (defparameter *sidebar-width* 30)
-(defparameter *food-density* 1/6000)
+(defparameter *food-density* 1/10000)
 (defparameter *clothing-density* 1/20000)
 (defparameter *jewelery-density* 1/20000)
 (defparameter *map-size* 2000)
@@ -14,6 +14,7 @@
 (defparameter *ruin-size-dev* 2.0)
 (defparameter *graffiti-chance* 1/10)
 (defparameter *flavor-chance* 1/300)
+(defparameter *flavor-cooldown* 200)
 
 (defcolors
   (+white-black+  charms/ll:COLOR_WHITE   charms/ll:COLOR_BLACK)
--- a/src/entities/food.lisp	Sun Jan 08 11:56:21 2017 +0000
+++ b/src/entities/food.lisp	Sun Jan 08 12:11:21 2017 +0000
@@ -26,12 +26,14 @@
                         "musty"
                         "salty"
                         "awful"
+                        "depressing"
+                        "like something else"
+                        "faintly of mice"
                         "better than nothing"
                         "questionable"
                         "pretty nice"
                         "expensive"
                         "horrifying"
-                        "like mice"
                         "like an old sock"))))
 
 (defun make-food (x y)
--- a/src/entities/player.lisp	Sun Jan 08 11:56:21 2017 +0000
+++ b/src/entities/player.lisp	Sun Jan 08 12:11:21 2017 +0000
@@ -16,7 +16,7 @@
         ((< energy-value 50.0) "very hungry")
         ((< energy-value 80.0) "hungry")
         ((< energy-value 95.0) "peckish")
-        ((< energy-value 100.0) "full")
+        ((<= energy-value 100.0) "full")
         (t "stuffed")))
 
 
@@ -29,16 +29,16 @@
 (defun make-player ()
   (create-entity 'player
     :coords/x (round (* 0.5 ap::*map-size*))
-    :coords/y (round (* 0.9 ap::*map-size*))
+    :coords/y (round (* 0.05 ap::*map-size*))
     :visible/glyph "@"
     :visible/color ap::+black-white+))
 
 
 (defun tick-player (player)
-  (zapf (player/energy player) (clamp 0.0 140.0 (- % 0.1))
+  (zapf (player/energy player) (clamp 0.0 140.0 (- % 0.3))
         (player/health player) (clamp 0.0 100.0
-                                      (+ % (if (minusp (player/energy player))
-                                             -0.1
+                                      (+ % (if (< (player/energy player) 1.0)
+                                             -0.5
                                              0.1)))))
 
 
--- a/src/flavor.lisp	Sun Jan 08 11:56:21 2017 +0000
+++ b/src/flavor.lisp	Sun Jan 08 12:11:21 2017 +0000
@@ -1,9 +1,15 @@
 (in-package :ap.flavor)
 
 (defparameter *animals* (read-file-into-form "data/animals.lisp"))
+(defparameter *cooldown* 0)
 
 (defun flavorp ()
-  (randomp ap::*flavor-chance*))
+  (if (plusp *cooldown*)
+    (progn (decf *cooldown*) nil)
+    (if (randomp ap::*flavor-chance*)
+      (progn (setf *cooldown* ap::*flavor-cooldown*)
+             t)
+      nil)))
 
 (defun animal ()
   (format nil "You see ~A ~A.~2%~A"
--- a/src/main.lisp	Sun Jan 08 11:56:21 2017 +0000
+++ b/src/main.lisp	Sun Jan 08 12:11:21 2017 +0000
@@ -419,7 +419,9 @@
   (let* ((player *player*)
          (dest-x (+ (coords/x player) dx))
          (dest-y (+ (coords/y player) dy)))
-    (when (passablep (aref *structures* dest-x dest-y))
+    (when (and (in-range-p 0 dest-x *map-size*)
+               (in-range-p 0 dest-y *map-size*)
+               (passablep (aref *structures* dest-x dest-y)))
       (coords-move-entity player dest-x dest-y))))
 
 (defun get-items ()