field is printed with ncurses instead of string concat

master
panki27 7 years ago
parent a085c46c06
commit cc5715abcc

@ -149,32 +149,34 @@ def print_playfield(playfield, screen):
currentline +=1 currentline +=1
#print headline #print headline
for rowindex, row in enumerate(playfield): for rowindex, row in enumerate(playfield):
rowstring = '|' screen.addstr(currentline, 10, '|')
pos = 11
for colindex, cell in enumerate(row): for colindex, cell in enumerate(row):
# is the cell selected? # is the cell selected?
selected = False selected = False
if [colindex, rowindex] == CURSOR_POSITION: if [colindex, rowindex] == CURSOR_POSITION:
rowstring += '[' screen.addstr(currentline, pos, '[')
selected = True selected = True
else: else:
rowstring += ' ' screen.addstr(currentline, pos, ' ')
pos += 1
# did we find a hint? # did we find a hint?
if cell > 0: if cell > 0:
rowstring += str(cell) screen.addstr(currentline, pos, str(cell))
elif cell == 0: elif cell == 0:
rowstring += ' ' screen.addstr(currentline, pos, ' ')
elif cell == UNKNOWN or cell == MINE: elif cell == UNKNOWN or cell == MINE:
rowstring+= '#' screen.addstr(currentline, pos, '#') #rowstring+= '#'
elif cell == FLAG_MINE or cell == FLAG: elif cell == FLAG_MINE or cell == FLAG:
rowstring += 'P' screen.addstr(currentline, pos, 'P') #rowstring += 'P'
#elif cell == MINE: #elif cell == MINE:
# rowstring += 'X' # rowstring += 'X'
pos += 1
if selected: if selected:
rowstring += ']|' screen.addstr(currentline, pos, ']|')
else: else:
rowstring+=' |' screen.addstr(currentline, pos, ' |')
#print rowstring pos += 2
screen.addstr(currentline, 10, rowstring)
currentline +=1 currentline +=1
if(rowindex < len(row)-1): if(rowindex < len(row)-1):
screen.addstr(currentline, 10, midline) screen.addstr(currentline, 10, midline)

Loading…
Cancel
Save