diff gamelib/gamegui.py @ 80:a40a76012bd7

Refactor message handling so we can deal with in the gui
author Neil Muller <drnlmuller@gmail.com>
date Wed, 09 May 2012 12:08:44 +0200
parents 8b06b07a1477
children 59afe9f92383
line wrap: on
line diff
--- a/gamelib/gamegui.py	Wed May 09 00:31:11 2012 +0200
+++ b/gamelib/gamegui.py	Wed May 09 12:08:44 2012 +0200
@@ -9,7 +9,8 @@
 from gamelib.gui_base import Window, TextLabel, font_small, font_medium
 from gamelib.gui import BigButton, ImageDrawable
 from gamelib.engine import PopWindow, AddWindow
-from gamelib.constants import WIDTH
+from gamelib.constants import (WIDTH, FAILURE, SUCCESS, NEW_SCIENCE,
+        NEW_SCHEMATIC)
 from gamelib.gamestate import Game
 
 
@@ -365,7 +366,17 @@
 
     def end_turn(self):
         self.game.cur_missions = self.activity.get_mission_list()
-        self.game.end_turn()
+        messages = self.game.end_turn()
+        # FIXME: Hook this up to a report window or something
+        for msg_type, msg in messages:
+            if msg_type == NEW_SCIENCE or msg_type == NEW_SCHEMATIC:
+                print msg
+            elif msg_type == FAILURE:
+                print 'Mission failure: %s' % msg
+            elif msg_type == SUCCESS:
+                print 'Success: %s' % msg
+            else:
+                print 'Unhandled result %d: %s' % (msg_type, msg)
         self.game.start_turn()
         self.update_labels()
         self.update_widgets()