fix some bugs
This commit is contained in:
parent
b8968208bd
commit
3289eab1f4
|
@ -3,5 +3,5 @@
|
||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.11" />
|
<option name="sdkName" value="Python 3.11" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
|
@ -5,7 +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$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" 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$/.idea/Переделка.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/Переделка.iml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/ShipField.py" beforeDir="false" afterPath="$PROJECT_DIR$/ShipField.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>
|
||||||
|
@ -46,13 +48,13 @@
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"last_opened_file_path": "C:/Users/Eduardo/Documents/Программирование с Артуром/HNS/hnc-eduard/HNS/Excercises/ShipCraft/Переделка"
|
"last_opened_file_path": "F:/hnc-eduard/HNS/Excercises/ShipCraft/Переделка",
|
||||||
|
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}]]></component>
|
||||||
<component name="RunManager" selected="Python.main">
|
<component name="RunManager">
|
||||||
<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>
|
||||||
|
@ -74,7 +76,6 @@
|
||||||
</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>
|
||||||
|
@ -96,7 +97,6 @@
|
||||||
</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>
|
||||||
|
@ -118,14 +118,12 @@
|
||||||
</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" />
|
||||||
|
@ -181,15 +179,4 @@
|
||||||
<MESSAGE value="код по 22 части урока" />
|
<MESSAGE value="код по 22 части урока" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="код по 22 части урока" />
|
<option name="LAST_COMMIT_MESSAGE" value="код по 22 части урока" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
|
||||||
<breakpoint-manager>
|
|
||||||
<breakpoints>
|
|
||||||
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
|
|
||||||
<url>file://$PROJECT_DIR$/main.py</url>
|
|
||||||
<line>155</line>
|
|
||||||
<option name="timeStamp" value="1" />
|
|
||||||
</line-breakpoint>
|
|
||||||
</breakpoints>
|
|
||||||
</breakpoint-manager>
|
|
||||||
</component>
|
|
||||||
</project>
|
</project>
|
|
@ -2,7 +2,7 @@
|
||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -28,7 +28,6 @@ class ShipField:
|
||||||
def from_json(self, obj):
|
def from_json(self, obj):
|
||||||
self.field = obj['field']
|
self.field = obj['field']
|
||||||
self.ships = obj['ships']
|
self.ships = obj['ships']
|
||||||
ShipField.field_size = obj['field_size']
|
|
||||||
self.field_mode = ShipMode.from_string(obj['field_mode'])
|
self.field_mode = ShipMode.from_string(obj['field_mode'])
|
||||||
self.ship_size = obj['ship_size']
|
self.ship_size = obj['ship_size']
|
||||||
self.ship_direction = ShipDirection.from_string(obj['ship_direction'])
|
self.ship_direction = ShipDirection.from_string(obj['ship_direction'])
|
||||||
|
@ -57,7 +56,7 @@ class ShipField:
|
||||||
|
|
||||||
elif self.field_mode == ShipMode.SHOOT:
|
elif self.field_mode == ShipMode.SHOOT:
|
||||||
shoot_result = self.shoot(row, col)
|
shoot_result = self.shoot(row, col)
|
||||||
return self.shoot(row, col) == ShootResult.EMPTY
|
return shoot_result == ShootResult.EMPTY
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -44,18 +44,19 @@ def colorize(view):
|
||||||
field = view.ship_field
|
field = view.ship_field
|
||||||
for i in range(len(field.field)):
|
for i in range(len(field.field)):
|
||||||
bg = "white"
|
bg = "white"
|
||||||
if field[i] == "1" and not view.enemy:
|
if field.field[i] == "1" and not view.enemy:
|
||||||
bg = 'pink'
|
bg = 'pink'
|
||||||
if field[i] == "\\":
|
if field.field[i] == "\\":
|
||||||
bg = 'red'
|
bg = 'grey'
|
||||||
if field[i] == "0":
|
if field.field[i] == "0":
|
||||||
bg = 'black'
|
bg = 'black'
|
||||||
if field[i] == "p":
|
if field.field[i] == "p":
|
||||||
bg = 'blue'
|
bg = 'blue'
|
||||||
if "+" in field[i] and view.enemy:
|
if field.field[i] == "r":
|
||||||
bg = 'orange'
|
|
||||||
if "r" in field[i]:
|
|
||||||
bg = 'red'
|
bg = 'red'
|
||||||
|
if "+" in field.field[i] and view.enemy:
|
||||||
|
bg = 'orange'
|
||||||
|
|
||||||
view.buttons[i].configure(bg=bg)
|
view.buttons[i].configure(bg=bg)
|
||||||
|
|
||||||
refresh_remaining_ships_label(view)
|
refresh_remaining_ships_label(view)
|
||||||
|
@ -74,8 +75,9 @@ def left_button_click(view, row, col):
|
||||||
action_result = view.ship_field.action(row, col)
|
action_result = view.ship_field.action(row, col)
|
||||||
|
|
||||||
if action_result and view_enemy and game_mode == GameMode.Battle:
|
if action_result and view_enemy and game_mode == GameMode.Battle:
|
||||||
enemy_shoot_result = ShootResult.UNDEFINED
|
|
||||||
# Ход соперника
|
# Ход соперника
|
||||||
|
enemy_shoot_result = ShootResult.UNDEFINED
|
||||||
|
|
||||||
while enemy_shoot_result != ShootResult.EMPTY:
|
while enemy_shoot_result != ShootResult.EMPTY:
|
||||||
my_row = random.randint(0, ShipField.field_size)
|
my_row = random.randint(0, ShipField.field_size)
|
||||||
my_col = random.randint(0, ShipField.field_size - 1)
|
my_col = random.randint(0, ShipField.field_size - 1)
|
||||||
|
@ -158,6 +160,7 @@ def next_game_mode():
|
||||||
update_game_mode()
|
update_game_mode()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update_game_mode():
|
def update_game_mode():
|
||||||
global game_mode
|
global game_mode
|
||||||
|
|
||||||
|
@ -193,7 +196,7 @@ def update_game_mode():
|
||||||
savebutton.grid(column=start_column_my_field, row=load_button_row, columnspan=4)
|
savebutton.grid(column=start_column_my_field, row=load_button_row, columnspan=4)
|
||||||
loadbutton.grid(column=start_column_my_field + 6, row=load_button_row, columnspan=4)
|
loadbutton.grid(column=start_column_my_field + 6, row=load_button_row, columnspan=4)
|
||||||
|
|
||||||
start_button.grid(column=start_column_my_field, row=load_button_row + 1, columnspan=4)
|
start_button.grid(column=start_column_my_field + 11, row=load_button_row, columnspan=4)
|
||||||
load_game_button.grid_forget()
|
load_game_button.grid_forget()
|
||||||
exit_button.grid_forget()
|
exit_button.grid_forget()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue