tmscli 0.2.4__tar.gz → 0.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import random
|
|
2
|
+
import argparse
|
|
2
3
|
class minesweeper():
|
|
3
4
|
def __init__(self,size,num):
|
|
4
5
|
self.size=size
|
|
@@ -109,6 +110,8 @@ def main_loop(board):
|
|
|
109
110
|
terminal_minesweeper.print_board(board)
|
|
110
111
|
cmd=input()
|
|
111
112
|
cmds=cmd.split()
|
|
113
|
+
if int(cmds[1])>terminal_minesweeper.size or int(cmds[1])<0 or int(cmds[2])>terminal_minesweeper.size or int(cmds[2])<0:
|
|
114
|
+
print('coordinate out of range, please try again')
|
|
112
115
|
if cmds[0]=='uc':
|
|
113
116
|
if (not board[int(cmds[1])-1][int(cmds[2])-1][0]) and (not board[int(cmds[1])-1][int(cmds[2])-1][1]):
|
|
114
117
|
board[int(cmds[1])-1][int(cmds[2])-1][0]=True
|
|
@@ -126,8 +129,19 @@ def main_loop(board):
|
|
|
126
129
|
board[int(cmds[1])-1][int(cmds[2])-1][0]=False
|
|
127
130
|
else:
|
|
128
131
|
print('already not flagged')
|
|
132
|
+
else:
|
|
133
|
+
print('unrecognised command, please try again')
|
|
129
134
|
terminal_minesweeper.check(board)
|
|
130
135
|
def run():
|
|
136
|
+
p=argparse.ArgumentParser(description='Minesweeper CLI')
|
|
137
|
+
p.add_argument(
|
|
138
|
+
'-r','--rules',
|
|
139
|
+
action='store_true',
|
|
140
|
+
help='gives rules'
|
|
141
|
+
)
|
|
142
|
+
args=p.parse_args()
|
|
143
|
+
if args.rules:
|
|
144
|
+
print_rules()
|
|
131
145
|
mines=terminal_minesweeper.get_mines()
|
|
132
146
|
board=terminal_minesweeper.create_starting_board(mines)
|
|
133
147
|
main_loop(board)
|
|
File without changes
|
|
File without changes
|