diff gamelib/gamestate.py @ 25:27570aca5d17

Fix some stupid bugs
author Neil Muller <drnlmuller@gmail.com>
date Sun, 06 May 2012 19:21:06 +0200
parents f6a3b213857b
children 4d9610c59efa
line wrap: on
line diff
--- a/gamelib/gamestate.py	Sun May 06 19:17:04 2012 +0200
+++ b/gamelib/gamestate.py	Sun May 06 19:21:06 2012 +0200
@@ -35,7 +35,7 @@
 
     def get_available_equipment(self):
         """Return a list of equipment we can produce and afford"""
-        available = [x for x in lab.science
+        available = [x for x in self.lab.science
                 if isinstance(x, products.Product) and x.COST <= self.money]
         return available
 
@@ -43,7 +43,10 @@
         # Attempt the missions
         mission_results = []
         for mission, equipment in self.cur_missions:
-            mission_results.appned(mission.attempt(equipment, self))
+            mission_results.append(mission.attempt(equipment, self))
+            if not mission.available:
+                # Mission no longer available, so we clean up
+                self.missions.remove(mission)
         # Do the science
         self.points -= len(self.cur_allocation)
         if self.points < 0:
@@ -52,7 +55,6 @@
         # Process mission results
         for result in mission_results:
             result.apply(self)
-        # Update the science state with result of spend_points
         for science in new_stuff:
             # FIXME: Update UI better.
             print "You learned new stuff:", science.NAME