From bfce363852bd28d5ed52388f48290119096ae969 Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Sat, 12 Apr 2014 12:35:35 +1000 Subject: Consistent ordering of players, colour key at top. --- robots/cursesviewer.py | 10 ++++++++-- 1 file 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: -- cgit v1.2.3