changeset 25:27570aca5d17

Fix some stupid bugs
author Neil Muller <drnlmuller@gmail.com>
date Sun, 06 May 2012 19:21:06 +0200
parents 23720d0fd9a0
children 5d699b1f7188
files gamelib/gamestate.py gamelib/missions.py
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
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
--- a/gamelib/missions.py	Sun May 06 19:17:04 2012 +0200
+++ b/gamelib/missions.py	Sun May 06 19:21:06 2012 +0200
@@ -21,6 +21,8 @@
             state.money += self.money
             state.reputation += self.reputation
             self.applied = True
+            # FIXME: Hook up to the UI
+            print self.message
         else:
             raise RuntimeError('attempted to apply result twice')
 
@@ -112,6 +114,10 @@
 
     def attempt(self, equipment, state):
         failures = []
+        if not equipment:
+            return Result(FAILURE, 0, 0, "Your attempt to rob the bank"
+                    " barehanded is unsuccessful. Fortunately, everyone is"
+                    " too stunned to impede your escape.")
         for item in equipment:
             if isinstance(item, DoomsdayVirus):
                 if state.reputation < 10: