WiP commit to not loose changes

This commit is contained in:
Artur Savitskiy 2024-02-26 18:44:13 +01:00
parent d22710da82
commit 1d9b2f0b34
1 changed files with 12 additions and 2 deletions

View File

@ -135,12 +135,22 @@ class ShipField:
if value is None: if value is None:
return return
if type(value) is not int and value.isnumeric: if type(value) is str and value.isnumeric():
value = int(value) value = int(value)
if type(value) is int and 1 <= value <= 4: if type(value) is int and 1 <= value <= 4:
self.ship_size = value 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): def toggle_ship_direction(self):
if self.ship_direction == 0: if self.ship_direction == 0:
self.ship_direction = 1 self.ship_direction = 1
@ -162,4 +172,4 @@ class ShipField:
ship_string += self.field[r * self.field_size + c] + ', ' ship_string += self.field[r * self.field_size + c] + ', '
print(ship_string[:-2]) print(ship_string[:-2])
#print(blocked_string[:-2] + ' ' + ship_string[:-2]) #print(blocked_string[:-2] + ' ' + ship_string[:-2])
print("********************************************************************") print("********************************************************************")