changeset 224:e4f9513c9dd0

Include mission name in the results
author Neil Muller <drnlmuller@gmail.com>
date Sat, 12 May 2012 22:33:05 +0200
parents 19aae2b701d1
children f8c05e6dc0e2
files gamelib/gamegui.py gamelib/gamestate.py gamelib/tests/repl_game.py
diffstat 3 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/gamelib/gamegui.py	Sat May 12 21:28:43 2012 +0200
+++ b/gamelib/gamegui.py	Sat May 12 22:33:05 2012 +0200
@@ -403,13 +403,15 @@
             self.add_child(results)
         else:
             y = 200
-            for msg_type, msg, loot in messages:
+            for mission, msg_type, msg, loot in messages:
                 # FIXME: Better widgets
                 if msg_type == GAME_WIN:
                     self._make_win_screen(turn, msg)
                     self.is_game_over = True
                     break
                 colour = self.message_colours.get(msg_type, (255, 255, 255))
+                if mission:
+                    msg = '%s: %s' % (mission, msg)
                 y = self.display_message(y, msg, loot, colour)
 
     def display_message(self, y, msg, loot, colour, font=font_medium):
--- a/gamelib/gamestate.py	Sat May 12 21:28:43 2012 +0200
+++ b/gamelib/gamestate.py	Sat May 12 22:33:05 2012 +0200
@@ -94,7 +94,8 @@
         # Attempt the missions
         mission_results = []
         for mission, equipment in self.cur_missions:
-            mission_results.append(mission.attempt_mission(equipment, self))
+            mission_results.append((mission.NAME,
+                mission.attempt_mission(equipment, self)))
         if not self.cur_missions and self.reputation > 0:
             # If you're not doing stuff, you're not in the news
             self.reputation -= M_VALS[self.milestone]
@@ -104,9 +105,9 @@
             raise RuntimeError('Spent too many points')
         # Process mission results
         messages = []
-        for result in mission_results:
+        for miss, result in mission_results:
             result.apply(self)
-            messages.append((result.outcome, result.text, result.loot))
+            messages.append((miss, result.outcome, result.text, result.loot))
         # Missions may give us science breakthroughs, so handle this after
         # mission results
         new_stuff = self.lab.spend_points(self.cur_allocation, self.points)
@@ -114,7 +115,7 @@
         self.minions = 0
         for science in new_stuff:
             # FIXME: Update UI better.
-            messages.append((INFO, "SCIENCE breakthrough!", {
+            messages.append((None, INFO, "SCIENCE breakthrough!", {
                         science.SCIENCE_TYPE: science}))
         return messages
 
--- a/gamelib/tests/repl_game.py	Sat May 12 21:28:43 2012 +0200
+++ b/gamelib/tests/repl_game.py	Sat May 12 22:33:05 2012 +0200
@@ -64,7 +64,9 @@
         self.game.cur_missions.extend(missions)
         print "-" * 10, "RESULTS", "-" * 31
         messages = self.game.end_turn()
-        for msg_type, msg in messages:
+        for miss, msg_type, msg in messages:
+            if miss:
+                print 'Mission: %s' % miss
             if msg_type == NEW_SCIENCE or msg_type == NEW_SCHEMATIC:
                 print msg
             elif msg_type == FAILURE: