From cc5715abcca461b248e039a17c385270c705c805 Mon Sep 17 00:00:00 2001 From: panki27 Date: Wed, 18 Apr 2018 20:28:04 +0200 Subject: [PATCH] field is printed with ncurses instead of string concat --- minebash.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/minebash.py b/minebash.py index feae435..06b25d2 100755 --- a/minebash.py +++ b/minebash.py @@ -149,32 +149,34 @@ def print_playfield(playfield, screen): currentline +=1 #print headline for rowindex, row in enumerate(playfield): - rowstring = '|' + screen.addstr(currentline, 10, '|') + pos = 11 for colindex, cell in enumerate(row): # is the cell selected? selected = False if [colindex, rowindex] == CURSOR_POSITION: - rowstring += '[' + screen.addstr(currentline, pos, '[') selected = True else: - rowstring += ' ' + screen.addstr(currentline, pos, ' ') + pos += 1 # did we find a hint? if cell > 0: - rowstring += str(cell) + screen.addstr(currentline, pos, str(cell)) elif cell == 0: - rowstring += ' ' + screen.addstr(currentline, pos, ' ') elif cell == UNKNOWN or cell == MINE: - rowstring+= '#' + screen.addstr(currentline, pos, '#') #rowstring+= '#' elif cell == FLAG_MINE or cell == FLAG: - rowstring += 'P' + screen.addstr(currentline, pos, 'P') #rowstring += 'P' #elif cell == MINE: # rowstring += 'X' + pos += 1 if selected: - rowstring += ']|' + screen.addstr(currentline, pos, ']|') else: - rowstring+=' |' - #print rowstring - screen.addstr(currentline, 10, rowstring) + screen.addstr(currentline, pos, ' |') + pos += 2 currentline +=1 if(rowindex < len(row)-1): screen.addstr(currentline, 10, midline)