restore_station()

This commit is contained in:
Tomasz Adamczyk 2021-04-03 00:22:42 +02:00
parent bbffd5b933
commit 30ccb27ab8
3 changed files with 36 additions and 33 deletions

View File

@ -3,10 +3,6 @@
<component name="ChangeListManager">
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/definitions.py" beforeDir="false" afterPath="$PROJECT_DIR$/definitions.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/plant.py" beforeDir="false" afterPath="$PROJECT_DIR$/plant.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/rail_detector_powered.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/tractor.py" beforeDir="false" afterPath="$PROJECT_DIR$/tractor.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -101,6 +97,7 @@
<workItem from="1617383739568" duration="1714000" />
<workItem from="1617396071094" duration="3170000" />
<workItem from="1617399305318" duration="2444000" />
<workItem from="1617401891560" duration="232000" />
</task>
<servers />
</component>
@ -108,22 +105,22 @@
<option name="version" value="1" />
</component>
<component name="WindowStateProjectService">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617401771495">
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617402125132">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617401771495" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617401771495">
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617402125132" />
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617402125132">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617401771495" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617401771494">
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617402125132" />
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617402125132">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617401771494" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617401771495">
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617402125132" />
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617402125132">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617401771495" />
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617402125132" />
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1617385468328">
<screen x="0" y="0" width="1920" height="1080" />
</state>
@ -140,12 +137,12 @@
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617385468328" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617396163208">
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617401891370">
<screen x="0" y="0" width="1920" height="1080" />
</state>
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617396163208" />
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617401891370" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1617401748390" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1617402000466" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

Binary file not shown.

View File

@ -49,6 +49,29 @@ class Tractor:
self.x = self.x + definitions.BLOCK_SIZE
def move_up(self):
self.y = self.y - definitions.BLOCK_SIZE
def station_restore(self, station1):
station1.set_collected_plants("beetroot",
station1.get_collected_plants("beetroot") + self.get_collected_plants("beetroot"))
self.set_collected_plants("beetroot", 0)
station1.set_collected_plants("carrot",
station1.get_collected_plants("carrot") + self.get_collected_plants("carrot"))
self.set_collected_plants("carrot", 0)
station1.set_collected_plants("potato",
station1.get_collected_plants("potato") + self.get_collected_plants("potato"))
self.set_collected_plants("potato", 0)
station1.set_collected_plants("wheat",
station1.get_collected_plants("wheat") + self.get_collected_plants("wheat"))
self.set_collected_plants("wheat", 0)
self.set_amount_of_seeds("beetroot", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_amount_of_seeds("carrot", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_amount_of_seeds("potato", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_amount_of_seeds("wheat", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_fertilizer("beetroot", definitions.TRACTOR_FERTILIZER)
self.set_fertilizer("carrot", definitions.TRACTOR_FERTILIZER)
self.set_fertilizer("potato", definitions.TRACTOR_FERTILIZER)
self.set_fertilizer("wheat", definitions.TRACTOR_FERTILIZER)
self.set_fuel(definitions.TRACTOR_FUEL)
self.set_water_level(definitions.TRACTOR_WATER_LEVEL)
def do_work(self, map1, station1, tractor1_rect):
loop = True
if self.get_all_amount_of_seeds() == 0:
@ -57,24 +80,7 @@ class Tractor:
y = int(tractor1_rect.y / definitions.BLOCK_SIZE)
field = map1.get_fields()[x][y]
if x == 0 and y == 0:
station1.set_collected_plants("beetroot", station1.get_collected_plants("beetroot") + self.get_collected_plants("beetroot"))
self.set_collected_plants("beetroot", 0)
station1.set_collected_plants("carrot", station1.get_collected_plants("carrot") + self.get_collected_plants("carrot"))
self.set_collected_plants("carrot", 0)
station1.set_collected_plants("potato", station1.get_collected_plants("potato") + self.get_collected_plants("potato"))
self.set_collected_plants("potato", 0)
station1.set_collected_plants("wheat", station1.get_collected_plants("wheat") + self.get_collected_plants("wheat"))
self.set_collected_plants("wheat", 0)
self.set_amount_of_seeds("beetroot", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_amount_of_seeds("carrot", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_amount_of_seeds("potato", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_amount_of_seeds("wheat", definitions.TRACTOR_AMOUNT_OF_SEEDS_EACH_TYPE)
self.set_fertilizer("beetroot", definitions.TRACTOR_FERTILIZER)
self.set_fertilizer("carrot", definitions.TRACTOR_FERTILIZER)
self.set_fertilizer("potato", definitions.TRACTOR_FERTILIZER)
self.set_fertilizer("wheat", definitions.TRACTOR_FERTILIZER)
self.set_fuel(definitions.TRACTOR_FUEL)
self.set_water_level(definitions.TRACTOR_WATER_LEVEL)
self.station_restore(station1)
elif field.get_soil().get_state() is False:
field.get_soil().set_state(True)
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is False and self.get_water_level() > 0: