summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ward <peteraward@gmail.com>2014-04-12 12:35:35 +1000
committerPeter Ward <peteraward@gmail.com>2014-04-12 12:35:35 +1000
commitbfce363852bd28d5ed52388f48290119096ae969 (patch)
tree2eeac6c3bba85b21e9945ac2b48059ffe5e8f3f5
parentbf28a0dc1402024077c910e4c2d5171217056a42 (diff)
Consistent ordering of players, colour key at top.
-rw-r--r--robots/cursesviewer.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/robots/cursesviewer.py b/robots/cursesviewer.py
index 4221117..257c425 100644
--- a/robots/cursesviewer.py
+++ b/robots/cursesviewer.py
@@ -21,14 +21,19 @@ class CursesViewer:
colours = cycle('red blue green yellow magenta cyan'.split())
self.player_colours = dict(zip(
- game.state.players,
+ sorted(game.state.players),
colours,
))
- self.player_colours[City.GHOST] = 'white'
def draw_board(self, state):
print(self.terminal.clear, end='')
+ players = []
+ for name, colour in sorted(self.player_colours.items()):
+ fn = getattr(self.terminal, 'on_' + colour)
+ players.append(fn(name))
+ print(' '.join(players))
+
width = len(state.board[0]) * 3
print(Box.TL + Box.H * width + Box.TR)
@@ -75,6 +80,7 @@ class CursesViewer:
for state in self.game:
next(limiter)
self.draw_board(state)
+# input()
winners = self.game.finished
if winners is True: