Mercurial > sypikslang
diff gamelib/tests/repl_game.py @ 23:f6a3b213857b
Fix up some game state logic, add very basic REPL game interface.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sun, 06 May 2012 19:06:28 +0200 |
parents | |
children | 5d699b1f7188 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gamelib/tests/repl_game.py Sun May 06 19:06:28 2012 +0200 @@ -0,0 +1,25 @@ +from gamelib.gamestate import Game + + +class ReplGame(object): + def __init__(self, init_data=None): + self.game = Game(init_data=init_data) + self._begin_turn() + + def _begin_turn(self): + self.game.start_turn() + self.display_state() + + def display_state(self): + print "Game:", self.game + print "Science:" + for science in self.game.lab.science: + print " %s %s (%s)" % ( + "*" if science.can_spend(self.game.lab) else "-", + science.NAME, science.points) + + def next_turn(self, research_list, missions): + self.game.cur_allocation.extend(research_list) + self.game.cur_missions.extend(missions) + self.game.end_turn() + self._begin_turn()