доработан код до 39 мин,но не стреляет
This commit is contained in:
parent
884e01b0e8
commit
9c97a90f20
Binary file not shown.
Binary file not shown.
|
@ -5,14 +5,9 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="b389cdea-22f5-4ba2-8b46-337091984b3c" name="Changes" comment="код по 22 части урока">
|
<list default="true" id="b389cdea-22f5-4ba2-8b46-337091984b3c" name="Changes" comment="код по 22 части урока">
|
||||||
<change beforePath="$PROJECT_DIR$/../../../../HNC/Excercises/hw1.py" beforeDir="false" afterPath="$PROJECT_DIR$/../../../../HNC/Excercises/hw1.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/../Переделка.rar" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/../../../../HNC/Excercises/hw2.py" beforeDir="false" afterPath="$PROJECT_DIR$/../../../../HNC/Excercises/hw2.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/../../../../HNC/Excercises/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/../../../../HNC/Excercises/main.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/../../../../HNC/Excercises/тест.py" beforeDir="false" afterPath="$PROJECT_DIR$/../../../../HNC/Excercises/тест.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/../../13082023 ДЗ по фигурам JSON/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/../../13082023 ДЗ по фигурам JSON/main.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/../../13082023 ДЗ по фигурам JSON/shapes.json" beforeDir="false" afterPath="$PROJECT_DIR$/../../13082023 ДЗ по фигурам JSON/shapes.json" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ShipView.py" beforeDir="false" afterPath="$PROJECT_DIR$/ShipView.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/ShipField.py" beforeDir="false" afterPath="$PROJECT_DIR$/ShipField.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
@ -44,20 +39,21 @@
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"Python.ShipField.executor": "Run",
|
"Python.ShipField.executor": "Run",
|
||||||
"Python.main (1).executor": "Run",
|
"Python.main (1).executor": "Run",
|
||||||
"Python.main.executor": "Run",
|
"Python.main.executor": "Run",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"last_opened_file_path": "Z:/Documents/Обучение с Новым Кодом (Артур)/Git/hnc-eduard/HNS/Excercises/ShipCraft/Переделка"
|
"last_opened_file_path": "C:/Users/Eduardo/Documents/Программирование с Артуром/HNS/hnc-eduard/HNS/Excercises/ShipCraft/Переделка"
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RunManager" selected="Python.main">
|
<component name="RunManager" selected="Python.main">
|
||||||
<configuration name="ShipField" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
<configuration name="ShipField" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
<module name="Переделка" />
|
<module name="Переделка" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
<envs>
|
<envs>
|
||||||
|
@ -79,6 +75,7 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="ShipView" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
<configuration name="ShipView" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
<module name="Переделка" />
|
<module name="Переделка" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
<envs>
|
<envs>
|
||||||
|
@ -100,6 +97,7 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="main (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
<configuration name="main (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
<module name="Переделка" />
|
<module name="Переделка" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
<envs>
|
<envs>
|
||||||
|
@ -121,12 +119,14 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
<module name="Переделка" />
|
<module name="Переделка" />
|
||||||
|
<option name="ENV_FILES" value="" />
|
||||||
<option name="INTERPRETER_OPTIONS" value="" />
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
<option name="PARENT_ENVS" value="true" />
|
<option name="PARENT_ENVS" value="true" />
|
||||||
<envs>
|
<envs>
|
||||||
<env name="PYTHONUNBUFFERED" value="1" />
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
</envs>
|
</envs>
|
||||||
<option name="SDK_HOME" value="$USER_HOME$/PycharmProjects/pythonProject/venv/bin/python" />
|
<option name="SDK_HOME" value="$USER_HOME$/PycharmProjects/pythonProject/venv/bin/python" />
|
||||||
|
<option name="SDK_NAME" value="Python 3.11" />
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||||
<option name="IS_MODULE_SDK" value="false" />
|
<option name="IS_MODULE_SDK" value="false" />
|
||||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
<component name="SharedIndexes">
|
<component name="SharedIndexes">
|
||||||
<attachedChunks>
|
<attachedChunks>
|
||||||
<set>
|
<set>
|
||||||
<option value="bundled-python-sdk-67fca87a943a-d3b881c8e49f-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-233.11799.259" />
|
<option value="bundled-python-sdk-babbdf50b680-746f403e7f0c-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.15989.155" />
|
||||||
</set>
|
</set>
|
||||||
</attachedChunks>
|
</attachedChunks>
|
||||||
</component>
|
</component>
|
||||||
|
@ -187,7 +187,7 @@
|
||||||
<breakpoints>
|
<breakpoints>
|
||||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
||||||
<url>file://$PROJECT_DIR$/main.py</url>
|
<url>file://$PROJECT_DIR$/main.py</url>
|
||||||
<line>135</line>
|
<line>147</line>
|
||||||
<option name="timeStamp" value="1" />
|
<option name="timeStamp" value="1" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
|
|
|
@ -56,7 +56,10 @@ class ShipField:
|
||||||
self.set_ship(row, col)
|
self.set_ship(row, col)
|
||||||
|
|
||||||
elif self.field_mode == ShipMode.SHOOT:
|
elif self.field_mode == ShipMode.SHOOT:
|
||||||
self.shoot(row, col)
|
shoot_result = self.shoot(row, col)
|
||||||
|
return self.shoot(row, col) == ShootResult.EMPTY
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def target(self, row, col):
|
def target(self, row, col):
|
||||||
self.clear_marker()
|
self.clear_marker()
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
import time
|
import time
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
|
@ -7,6 +8,7 @@ from ShipView import ShipView
|
||||||
from ShipMode import ShipMode
|
from ShipMode import ShipMode
|
||||||
from ShipField import ShipField
|
from ShipField import ShipField
|
||||||
from GameMode import GameMode
|
from GameMode import GameMode
|
||||||
|
from ShootResult import ShootResult
|
||||||
|
|
||||||
active_view = {}
|
active_view = {}
|
||||||
|
|
||||||
|
@ -69,7 +71,17 @@ def keypress_handler(e):
|
||||||
|
|
||||||
|
|
||||||
def left_button_click(view, row, col):
|
def left_button_click(view, row, col):
|
||||||
view.ship_field.action(row, col)
|
if view.ship_field.action(row, col) and view_enemy and game_mode == GameMode.Battle:
|
||||||
|
enemy_shoot_result = ShootResult.UNDEFINED
|
||||||
|
while enemy_shoot_result != ShootResult.EMPTY:
|
||||||
|
|
||||||
|
my_row = random.randint(0, ShipField.field_size)
|
||||||
|
my_col = random.randint(0, ShipField.field_size - 1)
|
||||||
|
|
||||||
|
enemy_shoot_result= my_view.ship_field.shoot(my_row, my_col)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
colorize(view)
|
colorize(view)
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,7 +174,7 @@ def update_game_mode():
|
||||||
elif game_mode == GameMode.PLAN:
|
elif game_mode == GameMode.PLAN:
|
||||||
window.geometry('1020x640')
|
window.geometry('1020x640')
|
||||||
|
|
||||||
load_field(view, file_path)
|
load_field(enemy_view, "default.json")
|
||||||
|
|
||||||
my_view.ship_field.set_field_mode(ShipMode.PUT)
|
my_view.ship_field.set_field_mode(ShipMode.PUT)
|
||||||
enemy_view.ship_field.set_field_mode(ShipMode.INACTIVE)
|
enemy_view.ship_field.set_field_mode(ShipMode.INACTIVE)
|
||||||
|
|
Loading…
Reference in New Issue