changeset 128:6a847f22a312

Don't restore selections if they're illegal
author Neil Muller <drnlmuller@gmail.com>
date Thu, 10 May 2012 16:37:17 +0200
parents 591a85a4edac
children be79e113d494
files gamelib/gamegui.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gamegui.py	Thu May 10 13:16:25 2012 +0200
+++ b/gamelib/gamegui.py	Thu May 10 16:37:17 2012 +0200
@@ -132,9 +132,11 @@
     def restore_selection(self, old_selection):
         points = old_selection.count(self.science)
         # We skip things we cannot allocate enoigh points to (temp points
-        # boosts, etc.)
+        # boosts, etc.) or we cannot currently develop further
         if (points != self.points and
-                points <= self.parent.game.get_available_points()):
+                points <= self.parent.game.get_available_points() and
+                self.science.can_spend(self.parent.game.lab,
+                    self.points + points)):
             self.points = points
             self.parent.game.cur_allocation.extend([self.science] * points)
             self.parent.update_labels()