Lint fix v1
This commit is contained in:
28
game/game.py
28
game/game.py
@@ -16,11 +16,9 @@ class Minesweeper:
|
||||
self.board_progress = board_progress
|
||||
|
||||
def create_board(self):
|
||||
""" Creating the board cells with 0 as default value """
|
||||
"""Creating the board cells with 0 as default value"""
|
||||
self.board = [[0 for col in range(self.cols)] for row in range(self.rows)]
|
||||
self.board_progress = [
|
||||
["-" for col in range(self.cols)] for row in range(self.rows)
|
||||
]
|
||||
self.board_progress = [['-' for col in range(self.cols)] for row in range(self.rows)]
|
||||
|
||||
def put_mine(self):
|
||||
"""Put a single mine on the board.
|
||||
@@ -36,7 +34,7 @@ class Minesweeper:
|
||||
return row, col
|
||||
|
||||
def put_mines(self):
|
||||
""" Put the desired amount of mines on the board """
|
||||
"""Put the desired amount of mines on the board"""
|
||||
for mine in range(1, self.mines + 1):
|
||||
row, col = self.put_mine()
|
||||
|
||||
@@ -71,31 +69,31 @@ class Minesweeper:
|
||||
self.increment_safe_point(row - 1, col - 1)
|
||||
|
||||
def is_mine(self, row, col):
|
||||
""" Checks whether the given location have a mine """
|
||||
"""Checks whether the given location have a mine"""
|
||||
if not self.is_point_in_board(row, col):
|
||||
return False
|
||||
return self.board[row][col] == -1
|
||||
|
||||
def is_empty(self, row, col):
|
||||
""" Checks whether the given location is empty """
|
||||
"""Checks whether the given location is empty"""
|
||||
if not self.is_point_in_board(row, col):
|
||||
return False
|
||||
return self.board[row][col] == 0
|
||||
|
||||
def is_point(self, row, col):
|
||||
""" Checks whether the given location have pontuation """
|
||||
"""Checks whether the given location have pontuation"""
|
||||
if not self.is_point_in_board(row, col):
|
||||
return False
|
||||
return self.board[row][col] > 0
|
||||
|
||||
def is_point_in_board(self, row, col):
|
||||
""" Checks whether the location is inside board """
|
||||
if row in range(0, self.rows) and col in range(0, self.cols):
|
||||
"""Checks whether the location is inside board"""
|
||||
if row in range(self.rows) and col in range(self.cols):
|
||||
return True
|
||||
return False
|
||||
|
||||
def increment_safe_point(self, row, col):
|
||||
""" Creates the mine's pontuation frame """
|
||||
"""Creates the mine's pontuation frame"""
|
||||
|
||||
# Ignores if the point whether not in the board
|
||||
if not self.is_point_in_board(row, col):
|
||||
@@ -129,7 +127,7 @@ class Minesweeper:
|
||||
while r < max_row:
|
||||
c = min_col
|
||||
while c < max_col:
|
||||
if not self.board[r][c] == -1 and self.board_progress[r][c] == "-":
|
||||
if not self.board[r][c] == -1 and self.board_progress[r][c] == '-':
|
||||
self.board_progress[r][c] = self.board[r][c]
|
||||
|
||||
if self.board[r][c] == 0:
|
||||
@@ -138,7 +136,7 @@ class Minesweeper:
|
||||
r += 1
|
||||
|
||||
def reveal(self, row, col):
|
||||
""" Reveals the cell's content and yours adjacents cells """
|
||||
"""Reveals the cell's content and yours adjacents cells"""
|
||||
self.board_progress[row][col] = self.board[row][col]
|
||||
|
||||
# We will show adjacents only if the cell clicked is zero
|
||||
@@ -146,14 +144,14 @@ class Minesweeper:
|
||||
self.reveal_adjacents(row, col)
|
||||
|
||||
def win(self):
|
||||
""" Identify if the player won the game """
|
||||
"""Identify if the player won the game"""
|
||||
unrevealed = 0
|
||||
for row in self.board_progress:
|
||||
for cell in row:
|
||||
if cell == -1:
|
||||
return False
|
||||
|
||||
if cell == "-":
|
||||
if cell == '-':
|
||||
unrevealed += 1
|
||||
if (unrevealed - self.mines) == 0:
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user