From 785392ed9261a1ee2a4ce3dfe8a1f2cedf0bd5ba Mon Sep 17 00:00:00 2001 From: ehermakov Date: Thu, 16 Nov 2023 21:41:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B6=D0=B0?= =?UTF-8?q?=D1=8E=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D1=83=201=20=D0=B8?= =?UTF-8?q?=D0=B7=20=D0=B4=D0=B7=20(=D1=87=D1=82=D0=BE=20=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D0=BB=D0=B8=20=D0=BD=D0=B0=20=D1=83=D1=80=D0=BE?= =?UTF-8?q?=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HNS/Excercises/ShipCraft/main.py | 15 +++++++-------- desktop.ini | 4 ++++ 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 desktop.ini diff --git a/HNS/Excercises/ShipCraft/main.py b/HNS/Excercises/ShipCraft/main.py index 33e7e50..74542ae 100644 --- a/HNS/Excercises/ShipCraft/main.py +++ b/HNS/Excercises/ShipCraft/main.py @@ -42,7 +42,7 @@ def set_ship(row, col, size, direction): return for r in range(row, row + size): index = r * field_size + col - my_field[index] = '1' + my_field[index] = "1" if direction == 1: if field_size - col < size: return @@ -58,7 +58,7 @@ def shoot(field, row, col): return ShootResult.UNDEFINED index = row * field_size + col if (field[index]).strip() == "": - field[index] = '0' + field[index] = "0" return ShootResult.EMPTY elif (field[index]).strip() == "1": field[index] = "\\" @@ -72,22 +72,22 @@ def draw_field(window, field): for c in range(0, field_size): index = r * field_size + c bg = 'white' - if field[index] == '1': + if field[index] == "1": bg = 'pink' btn = Button(window, text='', bg=bg, width=5, height=2) btn.grid(column=c, row=r) - btn.bind('', lambda e, x=r, y=c: shoot(field, x, y)) + btn.bind('', lambda e, x=r, y=c: button_click(field, x, y)) buttons.append(btn) def colorize(field, buttons): for i in range(len(field)): bg = "white" - if field[i] == '1': + if field[i] == "1": bg = 'pink' - if field[i] == '\\': + if field[i] == "\\": bg = 'red' - if field[i] == '0': + if field[i] == "0": bg = 'black' buttons[i].configure(bg=bg) @@ -107,5 +107,4 @@ set_ship(0, 0, 1, 0) set_ship(9, 0, 1, 0) set_ship(9, 2, 4, 1) draw_field(window, my_field) -colorize(my_field, buttons) window.mainloop() diff --git a/desktop.ini b/desktop.ini new file mode 100644 index 0000000..ab17096 --- /dev/null +++ b/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Documents