From 1d9b2f0b34358228990ce79ad4a295d6171363c6 Mon Sep 17 00:00:00 2001 From: Artur Savitskiy Date: Mon, 26 Feb 2024 18:44:13 +0100 Subject: [PATCH] WiP commit to not loose changes --- HNS/MB/ShipField.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/HNS/MB/ShipField.py b/HNS/MB/ShipField.py index e09fabb..f179f24 100644 --- a/HNS/MB/ShipField.py +++ b/HNS/MB/ShipField.py @@ -135,12 +135,22 @@ class ShipField: if value is None: return - if type(value) is not int and value.isnumeric: + if type(value) is str and value.isnumeric(): value = int(value) if type(value) is int and 1 <= value <= 4: self.ship_size = value + def set_ship_direction(self, value): + if value is None: + return + + if type(value) is str and value.isnumeric(): + value = int(value) + + if type(value) is int and 0 <= value <= 1: + self.ship_direction = value + def toggle_ship_direction(self): if self.ship_direction == 0: self.ship_direction = 1 @@ -162,4 +172,4 @@ class ShipField: ship_string += self.field[r * self.field_size + c] + ', ' print(ship_string[:-2]) #print(blocked_string[:-2] + ' ' + ship_string[:-2]) - print("********************************************************************") \ No newline at end of file + print("********************************************************************")