diff gamelib/tests/repl_game.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 52913ba12988
children e4f9513c9dd0
line wrap: on
line diff
--- a/gamelib/tests/repl_game.py	Wed May 09 00:31:11 2012 +0200
+++ b/gamelib/tests/repl_game.py	Wed May 09 12:08:44 2012 +0200
@@ -1,4 +1,5 @@
 from gamelib.gamestate import Game
+from gamelib.constants import SUCCESS, FAILURE, NEW_SCIENCE, NEW_SCHEMATIC
 
 
 class ReplGame(object):
@@ -62,5 +63,14 @@
         self.game.cur_allocation.extend(research_list)
         self.game.cur_missions.extend(missions)
         print "-" * 10, "RESULTS", "-" * 31
-        self.game.end_turn()
+        messages = self.game.end_turn()
+        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._begin_turn()