fixed cli arguments

master
panki27 7 years ago
parent 35b88812e8
commit a085c46c06

@ -29,7 +29,8 @@ if len(sys.argv) > 1:
if len(sys.argv) == 4: if len(sys.argv) == 4:
width = int(sys.argv[1]) width = int(sys.argv[1])
height = int(sys.argv[2]) height = int(sys.argv[2])
MINECOUNT = int(sys.argv[3]) if int(sys.argv[3]) < width*height:
MINECOUNT = int(sys.argv[3])
else: else:
print('Specify parameters as width height minecount (for example ./minebash.py 5 5 7)') print('Specify parameters as width height minecount (for example ./minebash.py 5 5 7)')
sys.exit(0) sys.exit(0)
@ -144,7 +145,7 @@ def gameover(win):
def print_playfield(playfield, screen): def print_playfield(playfield, screen):
currentline = 0 currentline = 0
screen.addstr(currentline, 0, headline) screen.addstr(currentline, 10, headline)
currentline +=1 currentline +=1
#print headline #print headline
for rowindex, row in enumerate(playfield): for rowindex, row in enumerate(playfield):
@ -173,12 +174,12 @@ def print_playfield(playfield, screen):
else: else:
rowstring+=' |' rowstring+=' |'
#print rowstring #print rowstring
screen.addstr(currentline, 0, rowstring) screen.addstr(currentline, 10, rowstring)
currentline +=1 currentline +=1
if(rowindex < len(row)-1): if(rowindex < len(row)-1):
screen.addstr(currentline, 0, midline) screen.addstr(currentline, 10, midline)
currentline +=1 currentline +=1
screen.addstr(currentline, 0, tailline) screen.addstr(currentline, 10, tailline)
currentline +=1 currentline +=1
#print tailline #print tailline
@ -246,7 +247,7 @@ def handle_input(k):
def print_score(screen): def print_score(screen):
scorestr = 'Mines: {} Flags: {}'.format(MINECOUNT, FLAGCOUNT) scorestr = 'Mines: {} Flags: {}'.format(MINECOUNT, FLAGCOUNT)
screen.addstr(19 ,0,scorestr) screen.addstr(19 ,20,scorestr)
def main(stdscr): def main(stdscr):
global SCREEN global SCREEN

Loading…
Cancel
Save