From 0b49012756c4e68fd0fa7d44907483b0b0932e88 Mon Sep 17 00:00:00 2001 From: Peter Ward Date: Mon, 7 Apr 2014 17:44:25 +1000 Subject: render factories --- robots/cursesviewer.py | 11 ++++++++++- simple.py | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/robots/cursesviewer.py b/robots/cursesviewer.py index 4d94491..bd26ef2 100644 --- a/robots/cursesviewer.py +++ b/robots/cursesviewer.py @@ -2,6 +2,7 @@ from itertools import cycle from blessings import Terminal +from robots.constants import City from robots.utils import rate_limit class Box: @@ -45,8 +46,16 @@ class CursesViewer: if foreground == background: foreground = 'white' + if cell['city'] == City.FACTORY: + value = '[%s]' % energy + else: + value = '<%s>' % energy + func = getattr(self.terminal, foreground) - value = func('<%d>') % energy + value = func(value) + + elif cell['city'] == City.FACTORY: + value = '[ ]' if background: func = getattr(self.terminal, 'on_' + background) diff --git a/simple.py b/simple.py index 10dba02..335fa08 100644 --- a/simple.py +++ b/simple.py @@ -119,6 +119,10 @@ if __name__ == '__main__': map_[5][15] = '3' map_[5][25] = '2' + for y in (2, 8): + for x in (5, 15, 25): + map_[y][x] = '+' + game = robots.Game(map_) game.add_bot(bot, 'Alice') game.add_bot(bot, 'Bob') -- cgit v1.2.3