tmscli 0.2.5__tar.gz → 0.2.7__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.5
3
+ Version: 0.2.7
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.5"
7
+ version = "0.2.7"
8
8
  description = "runs minesweeper in your terminal, type rules for how to play"
9
9
  dependencies = []
10
10
 
@@ -1,15 +1,17 @@
1
1
  import random
2
+ import argparse
2
3
  class minesweeper():
3
4
  def __init__(self,size,num):
4
5
  self.size=size
5
6
  self.num=num
6
7
  ['uncovered?','flagged?','display']
7
8
  def print_board(self,board):
8
-
9
- top=' 1 2 3 4 5 6 7 8 9'
10
- print(top)
9
+ top=(len(str(self.size))+2)*' '
10
+ for i in range(self.size):
11
+ top+=str(i+1)+' '
12
+ print(top[:-1])
11
13
  for i in range(self.size):
12
- if i==10:
14
+ if 100>i>9:
13
15
  buffer=str(i+1)+' '
14
16
  else:
15
17
  buffer=str(i+1)+' '
@@ -109,7 +111,7 @@ def main_loop(board):
109
111
  terminal_minesweeper.print_board(board)
110
112
  cmd=input()
111
113
  cmds=cmd.split()
112
- if cmds[1]>terminal_minesweeper.size or cmds[1]<0 or cmds[2]>terminal_minesweeper.size or cmds[2]<0:
114
+ if int(cmds[1])>terminal_minesweeper.size or int(cmds[1])<0 or int(cmds[2])>terminal_minesweeper.size or int(cmds[2])<0:
113
115
  print('coordinate out of range, please try again')
114
116
  if cmds[0]=='uc':
115
117
  if (not board[int(cmds[1])-1][int(cmds[2])-1][0]) and (not board[int(cmds[1])-1][int(cmds[2])-1][1]):
@@ -132,6 +134,23 @@ def main_loop(board):
132
134
  print('unrecognised command, please try again')
133
135
  terminal_minesweeper.check(board)
134
136
  def run():
137
+ p=argparse.ArgumentParser(description='Minesweeper CLI')
138
+ p.add_argument(
139
+ '-r','--rules',
140
+ action='store_true',
141
+ help='gives rules'
142
+ )
143
+ p.add_argument(
144
+ '-s','--size',
145
+ type=int,
146
+ default=9,
147
+ help='set size to x'
148
+ )
149
+ args=p.parse_args()
150
+ if args.rules:
151
+ print_rules()
152
+ if args.size:
153
+ terminal_minesweeper.size=args.size
135
154
  mines=terminal_minesweeper.get_mines()
136
155
  board=terminal_minesweeper.create_starting_board(mines)
137
156
  main_loop(board)
@@ -154,4 +173,5 @@ Aim:
154
173
  uncover every square without a mine on it
155
174
 
156
175
  If you step on a mine you lose, the number on the square is how many mines are around it (3 x 3 radius)
157
- ''')
176
+ ''')
177
+ run()
File without changes
File without changes