9aad3f5f030b

Add a win condition
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sun, 08 Jan 2017 13:19:27 +0000
parents f29a23574bd3
children 7498a056c40c
branches/tags (none)
files data/win.txt src/main.lisp

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/win.txt	Sun Jan 08 13:19:27 2017 +0000
@@ -0,0 +1,7 @@
+As you walk north into the Arctic circle the
+heat finally begins to subside.  Bits of grass
+poke up through the dirt, drinking in the
+massive amounts carbon dioxide in the atmosphere.
+
+You can finally rest for a few months, until
+summer arrives and you must head south again.
--- a/src/main.lisp	Sun Jan 08 13:11:40 2017 +0000
+++ b/src/main.lisp	Sun Jan 08 13:19:27 2017 +0000
@@ -10,6 +10,7 @@
 (defparameter *intro6* (read-file-into-string "data/intro6.txt"))
 (defparameter *help* (read-file-into-string "data/help.txt"))
 (defparameter *death* (read-file-into-string "data/death.txt"))
+(defparameter *win* (read-file-into-string "data/win.txt"))
 
 (defparameter *starving-cooldown* 0)
 (defparameter *screen-width* nil)
@@ -319,6 +320,12 @@
   (popup "Thanks for playing!"))
 
 
+;;;; Winning ------------------------------------------------------------------
+(defun win ()
+  (popup *win*)
+  (popup "Thanks for playing!"))
+
+
 ;;;; World Map ----------------------------------------------------------------
 (defun terrain-rand-p (height)
   (evenp (truncate (* 100 (mod height 0.1)))))
@@ -530,6 +537,10 @@
       nil)))
 
 
+(defun check-win ()
+  (= 0 (coords/y *player*)))
+
+
 (defun world-map ()
   (with-dims ((- *screen-width* 2) (- *screen-height* 1))
     (with-panels-and-windows
@@ -546,12 +557,12 @@
         (if-first-time
           (popup (format nil "You must head north to survive.~2%You can press h for help in-game."))
           (cond
+            ((check-win) (return (win)))
+            ((player-dead-p *player*) (return (death)))
             ((check-starvation-warning)
              (display-starvation-warning))
             ((ap.flavor:flavorp)
              (popup (ap.flavor:random-flavor)))
-            ((player-dead-p *player*)
-             (return (death)))
             (t (case (world-map-input bar-win)
                  (:tick (tick-player *player*)
                   (check-triggers))