We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 371891b commit 2dfc8d1Copy full SHA for 2dfc8d1
1 file changed
Minesweep/code.py
@@ -136,6 +136,22 @@ def expand_uncovered(start_x, start_y):
136
return number_uncovered
137
138
139
+def check_for_win():
140
+ """Check for a complete, winning game. That's one with all squares uncovered
141
+ and all bombs correctly flagged, with no non-bomb squares flaged.
142
+ """
143
+ for x in range(20):
144
+ for y in range(15):
145
+ visible = tilegrid[x, y]
146
+ under = get_data(x, y)
147
+ if visible == BLANK:
148
+ print('Found a unexplored square at (%d, %d)' % (x, y))
149
+ return False #still covewred squares, not done
150
+ elif visible == BOMBFLAGGED and under != BOMB:
151
+ print('Found misflagged bomb at (%d, %d)' % (x, y))
152
+ return False #misflagged bombs, not done
153
+ return True
154
+
155
def play_a_game():
156
number_uncovered = 0
157
touch_x = -1
0 commit comments