changeset 58:52913ba12988

Check for multiple points in can_spend
author Neil Muller <drnlmuller@gmail.com>
date Mon, 07 May 2012 23:20:41 +0200
parents 9aa0252fb6e4
children 977224a5c663
files gamelib/game_base.py gamelib/lab.py gamelib/schematics.py gamelib/tests/repl_game.py
diffstat 4 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/game_base.py	Mon May 07 23:13:05 2012 +0200
+++ b/gamelib/game_base.py	Mon May 07 23:20:41 2012 +0200
@@ -22,7 +22,7 @@
     def spend_point(self):
         self.points += 1
 
-    def can_spend(self, lab):
+    def can_spend(self, lab, spend):
         return True
 
     @classmethod
--- a/gamelib/lab.py	Mon May 07 23:13:05 2012 +0200
+++ b/gamelib/lab.py	Mon May 07 23:20:41 2012 +0200
@@ -66,7 +66,7 @@
         # First, allocate the points.
         for thing in things:
             assert thing in self.science
-            assert thing.can_spend(self)
+            assert thing.can_spend(self, 1)
             thing.spend_point()
 
         # Next, check for schematic breakthroughs and upgrades
--- a/gamelib/schematics.py	Mon May 07 23:13:05 2012 +0200
+++ b/gamelib/schematics.py	Mon May 07 23:20:41 2012 +0200
@@ -30,8 +30,8 @@
     BASE_POWER = None
     POWER_INCREMENT = None
 
-    def can_spend(self, lab):
-        extra = self.UPGRADE_REQUIREMENT * self.points + 1
+    def can_spend(self, lab, spend):
+        extra = self.UPGRADE_REQUIREMENT * self.points + spend
         return lab.meet_requirements(self, extra)
 
     def is_a(self, category):
@@ -62,7 +62,7 @@
     def spend_point(self):
         raise NotImplementedError()
 
-    def can_spend(self, lab):
+    def can_spend(self, lab, spend):
         return False
 
 
--- a/gamelib/tests/repl_game.py	Mon May 07 23:13:05 2012 +0200
+++ b/gamelib/tests/repl_game.py	Mon May 07 23:20:41 2012 +0200
@@ -19,7 +19,7 @@
         print "Science:"
         self.science = []
         for science in self.game.lab.science:
-            if science.can_spend(self.game.lab):
+            if science.can_spend(self.game.lab, 1):
                 self.science.append(science)
                 print " %s. %s (%s)" % (
                     len(self.science), science.NAME, science.points)