diff --git a/HNS/Excercises/ShipCraft/Переделка/.idea/misc.xml b/HNS/Excercises/ShipCraft/Переделка/.idea/misc.xml
index a6218fe..94888fc 100644
--- a/HNS/Excercises/ShipCraft/Переделка/.idea/misc.xml
+++ b/HNS/Excercises/ShipCraft/Переделка/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/HNS/Excercises/ShipCraft/Переделка/.idea/workspace.xml b/HNS/Excercises/ShipCraft/Переделка/.idea/workspace.xml
index d6e083c..6ed4e92 100644
--- a/HNS/Excercises/ShipCraft/Переделка/.idea/workspace.xml
+++ b/HNS/Excercises/ShipCraft/Переделка/.idea/workspace.xml
@@ -4,7 +4,15 @@
-
+
+
+
+
+
+
+
+
+
@@ -34,21 +42,20 @@
- {
+ "keyToString": {
+ "Python.ShipField.executor": "Run",
+ "Python.main (1).executor": "Run",
+ "Python.main.executor": "Debug",
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "git-widget-placeholder": "main",
+ "last_opened_file_path": "C:/Users/Eduardo/Documents/Программирование с Артуром/HNS/hnc-eduard/HNS/Excercises/ShipCraft"
}
-}]]>
+}
-
@@ -70,7 +77,6 @@
-
@@ -92,7 +98,6 @@
-
@@ -114,7 +119,6 @@
-
@@ -170,7 +174,7 @@
file://$PROJECT_DIR$/main.py
- 133
+ 129
diff --git a/HNS/Excercises/ShipCraft/Переделка/.idea/Переделка.iml b/HNS/Excercises/ShipCraft/Переделка/.idea/Переделка.iml
index d0876a7..8388dbc 100644
--- a/HNS/Excercises/ShipCraft/Переделка/.idea/Переделка.iml
+++ b/HNS/Excercises/ShipCraft/Переделка/.idea/Переделка.iml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/HNS/Excercises/ShipCraft/Переделка/GameMode.py b/HNS/Excercises/ShipCraft/Переделка/GameMode.py
new file mode 100644
index 0000000..8ae75d1
--- /dev/null
+++ b/HNS/Excercises/ShipCraft/Переделка/GameMode.py
@@ -0,0 +1,16 @@
+from enum import Enum
+
+
+class GameMode(Enum):
+ MENU = 'MENU'
+ PLAN = 'PLAN'
+ BATTLE = 'BATTLE'
+ END = 'END'
+
+ @staticmethod
+ def from_string(raw_value):
+ if raw_value:
+ value = raw_value.upper()
+ if value in GameMode.__members__:
+ return GameMode[value]
+ return GameMode.MENU
diff --git a/HNS/Excercises/ShipCraft/Переделка/ShipField.py b/HNS/Excercises/ShipCraft/Переделка/ShipField.py
index 467a5b0..d4442c8 100644
--- a/HNS/Excercises/ShipCraft/Переделка/ShipField.py
+++ b/HNS/Excercises/ShipCraft/Переделка/ShipField.py
@@ -21,7 +21,7 @@ class ShipField:
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
self.ships = [4, 3, 3, 2, 2, 2, 1, 1, 1, 1]
- self.field_mode = ShipMode.PUT
+ self.field_mode = ShipMode.INACTIVE
self.ship_size = 4
self.ship_direction = ShipDirection.VERTICAL
@@ -76,7 +76,7 @@ class ShipField:
self.field[row * ShipField.field_size + c] = "p"
else:
self.field[row * ShipField.field_size + c] = "r"
- else:
+ elif self.field_mode == ShipMode.SHOOT:
self.field[row * ShipField.field_size + col] += "+"
def clear_marker(self):
diff --git a/HNS/Excercises/ShipCraft/Переделка/ShipMode.py b/HNS/Excercises/ShipCraft/Переделка/ShipMode.py
index f9e97b8..dbffd33 100644
--- a/HNS/Excercises/ShipCraft/Переделка/ShipMode.py
+++ b/HNS/Excercises/ShipCraft/Переделка/ShipMode.py
@@ -4,7 +4,7 @@ from enum import Enum
class ShipMode(Enum):
PUT = 'PUT'
SHOOT = 'SHOOT'
- UNKNOWN = 'UNKNOWN'
+ INACTIVE = 'INACTIVE'
@staticmethod
def from_string(raw_value):
@@ -12,6 +12,6 @@ class ShipMode(Enum):
value = raw_value.upper()
if value in ShipMode.__members__:
return ShipMode[value]
- return ShipMode.UNKNOWN
+ return ShipMode.INACTIVE
diff --git a/HNS/Excercises/ShipCraft/Переделка/__pycache__/GameMode.cpython-39.pyc b/HNS/Excercises/ShipCraft/Переделка/__pycache__/GameMode.cpython-39.pyc
new file mode 100644
index 0000000..a3548cc
Binary files /dev/null and b/HNS/Excercises/ShipCraft/Переделка/__pycache__/GameMode.cpython-39.pyc differ
diff --git a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipDirection.cpython-39.pyc b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipDirection.cpython-39.pyc
index a254960..d96d04c 100644
Binary files a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipDirection.cpython-39.pyc and b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipDirection.cpython-39.pyc differ
diff --git a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipField.cpython-39.pyc b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipField.cpython-39.pyc
index f6a2fe3..7ed55d5 100644
Binary files a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipField.cpython-39.pyc and b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipField.cpython-39.pyc differ
diff --git a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipMode.cpython-39.pyc b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipMode.cpython-39.pyc
index c4d34e1..23aaee9 100644
Binary files a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipMode.cpython-39.pyc and b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipMode.cpython-39.pyc differ
diff --git a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipView.cpython-39.pyc b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipView.cpython-39.pyc
index 39ee5d8..3ff97a5 100644
Binary files a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipView.cpython-39.pyc and b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShipView.cpython-39.pyc differ
diff --git a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShootResult.cpython-39.pyc b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShootResult.cpython-39.pyc
index 0f87191..f4d78ee 100644
Binary files a/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShootResult.cpython-39.pyc and b/HNS/Excercises/ShipCraft/Переделка/__pycache__/ShootResult.cpython-39.pyc differ
diff --git a/HNS/Excercises/ShipCraft/Переделка/__pycache__/test_ShipField.cpython-39.pyc b/HNS/Excercises/ShipCraft/Переделка/__pycache__/test_ShipField.cpython-39.pyc
new file mode 100644
index 0000000..8316be0
Binary files /dev/null and b/HNS/Excercises/ShipCraft/Переделка/__pycache__/test_ShipField.cpython-39.pyc differ
diff --git a/HNS/Excercises/ShipCraft/Переделка/main.py b/HNS/Excercises/ShipCraft/Переделка/main.py
index 5cf8d83..3004a88 100644
--- a/HNS/Excercises/ShipCraft/Переделка/main.py
+++ b/HNS/Excercises/ShipCraft/Переделка/main.py
@@ -5,7 +5,9 @@ from tkinter import *
from tkinter import filedialog
from ShipView import ShipView
from ShipField import ShipField
+from GameMode import GameMode
+game_mode = GameMode.MENU
active_view ={}
def create_view(window, col_offset=0, row_offset=0):
@@ -50,9 +52,6 @@ def keypress_handler(e):
global active_view
if e.keysym.isnumeric():
active_view.ship_field.set_ship_size(e.keysym)
- else:
- if e.keysym == 'm':
- active_view.ship_field.toggle_field_mode()
def left_button_click(view, row, col):
@@ -106,7 +105,7 @@ def refresh_remaining_ships_label(view):
window = Tk()
window.title("Ship Craft!")
-window.geometry('1020x540')
+window.geometry('1020x640')
window.bind_all('', keypress_handler)
start_column_my_field = 1
@@ -150,6 +149,13 @@ savebutton_enemy = Button(window, text='Save', width=20, height=2, command=lambd
savebutton_enemy.grid(column=start_column_enemy_field, row=load_button_row, columnspan=4)
loadbutton_enemy = Button(window, text='Load', width=20, height=2, command=lambda: loadbutton_click(enemy_view))
-loadbutton_enemy.grid(column=start_column_enemy_field + 6, row=load_button_row, columnspan=4)
+loadbutton_enemy.grid(column=start_column_enemy_field + 6, row=load_button_row + 1, columnspan=4)
+
+prev_button = Button(window, text='<=', width=20, height=2)
+prev_button.grid(column=start_column_enemy_field, row=load_button_row, columnspan=4)
+
+
+next_button = Button(window, text='>=', width=20, height=2)
+next_button.grid(column=start_column_enemy_field + 6, row=load_button_row, columnspan=4)
window.mainloop()