diff gamelib/gameboard.py @ 307:bf1df0902883

three game modes: fortnight, quarter, fox extinction
author Adrianna Pińska <adrianna.pinska@gmail.com>
date Sat, 05 Sep 2009 18:01:37 +0000
parents 32149b1d9fd2
children 49c58dda8ac2
line wrap: on
line diff
--- a/gamelib/gameboard.py	Sat Sep 05 17:36:53 2009 +0000
+++ b/gamelib/gameboard.py	Sat Sep 05 18:01:37 2009 +0000
@@ -1030,9 +1030,15 @@
                 building.place(self.tv)
                 self.add_building(building)
 
+    def trees_left(self):
+        width, height = self.tv.size
+        return len([(x,y) for x in range(width) for y in range(height) if self.tv.get((x,y)) == self.WOODLAND])
+
     def is_game_over(self):
         """Return true if we're complete"""
-        if self.days > constants.TURN_LIMIT:
+        if self.trees_left() == 0:
+            return True
+        if constants.TURN_LIMIT > 0 and self.days > constants.TURN_LIMIT:
             return True
         if len(self.chickens) == 0:
             return True