diff --git a/HNS/Excercises/ShipCraft/Переделка/ShipField.py b/HNS/Excercises/ShipCraft/Переделка/ShipField.py index c296e4f..3671d15 100644 --- a/HNS/Excercises/ShipCraft/Переделка/ShipField.py +++ b/HNS/Excercises/ShipCraft/Переделка/ShipField.py @@ -286,6 +286,11 @@ class ShipField: return self.field[row * ShipField.field_size + col].strip() == "\\" def check_empty(self, row, col): + if row < 0 or row > ShipField.field_size - 1: + return False + if col < 0 or col > ShipField.field_size - 1: + return False + cell = self.field[row * ShipField.field_size + col].strip() return cell == "0" or cell == "" diff --git a/HNS/Excercises/ShipCraft/Переделка/main.py b/HNS/Excercises/ShipCraft/Переделка/main.py index 90f35ec..ab11e1b 100644 --- a/HNS/Excercises/ShipCraft/Переделка/main.py +++ b/HNS/Excercises/ShipCraft/Переделка/main.py @@ -11,7 +11,6 @@ from GameMode import GameMode from ShootResult import ShootResult - def create_view(window, enemy): field = ShipField() buttons = [] @@ -27,6 +26,7 @@ def create_view(window, enemy): colorize(view) return view + def show_view(view, col_offset=0, row_offset=0): field_size = view.ship_field.field_size @@ -140,6 +140,7 @@ def load_field(view, file_path): colorize(view) + def refresh_remaining_ships_label(view): text = '' for i in range(1, 5): @@ -162,7 +163,6 @@ def next_game_mode(): update_game_mode() - def update_game_mode(): global game_mode