diff --git a/HNS/Excercises/ShipCraft/main.py b/HNS/Excercises/ShipCraft/main.py index b05d62f..fc7e8f1 100644 --- a/HNS/Excercises/ShipCraft/main.py +++ b/HNS/Excercises/ShipCraft/main.py @@ -34,7 +34,7 @@ class ShootResult(Enum): UNDEFINED = "UNDEFINED" -def set_ship(row, col, ship_size, direction): +def set_ship(field, row, col, ship_size, direction): if row < 0 or row > field_size: return if col < 0 or col > field_size: @@ -45,13 +45,13 @@ def set_ship(row, col, ship_size, direction): return for r in range(row, row + ship_size): index = r * field_size + col - my_field[index] = "1" + field[index] = "1" if direction == 1: if field_size - col < ship_size: return for c in range(col, col + ship_size): index = row * field_size + c - my_field[index] = "1" + field[index] = "1" def shoot(field, row, col): @@ -113,7 +113,7 @@ def keypress_handler(e): def left_button_click(field, row, col): if field_mode == 0: if check_possible(field, row, col): - set_ship(row, col, ship_size, ship_direction) + set_ship(field, row, col, ship_size, ship_direction) elif field_mode == 1: shoot(field, row, col) colorize(field, buttons) @@ -185,9 +185,9 @@ window = Tk() window.title("Ship Craft!") window.geometry('450x410') window.bind_all('', keypress_handler) -set_ship(1, 1, 4, 1) -set_ship(0, 6, 3, 0) -set_ship(7, 3, 1, 0) +set_ship(my_field, 1, 1, 4, 1) +set_ship(my_field,0, 6, 3, 0) +set_ship(my_field, 7, 3, 1, 0) draw_field(window, my_field) window.mainloop()