Mercurial > sypikslang
comparison 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 |
comparison
equal
deleted
inserted
replaced
22:296ce36fa7d9 | 23:f6a3b213857b |
---|---|
1 from gamelib.gamestate import Game | |
2 | |
3 | |
4 class ReplGame(object): | |
5 def __init__(self, init_data=None): | |
6 self.game = Game(init_data=init_data) | |
7 self._begin_turn() | |
8 | |
9 def _begin_turn(self): | |
10 self.game.start_turn() | |
11 self.display_state() | |
12 | |
13 def display_state(self): | |
14 print "Game:", self.game | |
15 print "Science:" | |
16 for science in self.game.lab.science: | |
17 print " %s %s (%s)" % ( | |
18 "*" if science.can_spend(self.game.lab) else "-", | |
19 science.NAME, science.points) | |
20 | |
21 def next_turn(self, research_list, missions): | |
22 self.game.cur_allocation.extend(research_list) | |
23 self.game.cur_missions.extend(missions) | |
24 self.game.end_turn() | |
25 self._begin_turn() |