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,4 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tmscli
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: runs minesweeper in your terminal, type rules for how to play
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "tmscli"
7
- version = "0.2.4"
7
+ version = "0.2.6"
8
8
  description = "runs minesweeper in your terminal, type rules for how to play"
9
9
  dependencies = []
10
10
 
@@ -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