dodanie stacji
This commit is contained in:
parent
9ab7b66267
commit
2b38eb30f3
@ -4,9 +4,8 @@
|
|||||||
<list default="true" id="56453584-72bd-49f4-a39c-fccf91ab20c6" name="Default Changelist" comment="">
|
<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$/.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$/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$/fertilizer.py" beforeDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/py.py" beforeDir="false" afterPath="$PROJECT_DIR$/py.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/soil.py" beforeDir="false" afterPath="$PROJECT_DIR$/soil.py" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/tractor.py" beforeDir="false" afterPath="$PROJECT_DIR$/tractor.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/tractor.py" beforeDir="false" afterPath="$PROJECT_DIR$/tractor.py" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@ -90,6 +89,7 @@
|
|||||||
<workItem from="1616517453952" duration="124000" />
|
<workItem from="1616517453952" duration="124000" />
|
||||||
<workItem from="1616517732434" duration="704000" />
|
<workItem from="1616517732434" duration="704000" />
|
||||||
<workItem from="1616874983490" duration="2052000" />
|
<workItem from="1616874983490" duration="2052000" />
|
||||||
|
<workItem from="1617029025208" duration="4359000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@ -97,22 +97,22 @@
|
|||||||
<option name="version" value="1" />
|
<option name="version" value="1" />
|
||||||
</component>
|
</component>
|
||||||
<component name="WindowStateProjectService">
|
<component name="WindowStateProjectService">
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1616877053760">
|
<state width="1879" height="295" key="GridCell.Tab.0.bottom" timestamp="1617033424354">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1616877053760" />
|
<state width="1879" height="295" key="GridCell.Tab.0.bottom/0.0.1920.1080@0.0.1920.1080" timestamp="1617033424354" />
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1616877053760">
|
<state width="1879" height="295" key="GridCell.Tab.0.center" timestamp="1617033424354">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1616877053760" />
|
<state width="1879" height="295" key="GridCell.Tab.0.center/0.0.1920.1080@0.0.1920.1080" timestamp="1617033424354" />
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1616877053760">
|
<state width="1879" height="295" key="GridCell.Tab.0.left" timestamp="1617033424354">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1616877053760" />
|
<state width="1879" height="295" key="GridCell.Tab.0.left/0.0.1920.1080@0.0.1920.1080" timestamp="1617033424354" />
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1616877053760">
|
<state width="1879" height="295" key="GridCell.Tab.0.right" timestamp="1617033424354">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616877053760" />
|
<state width="1879" height="295" key="GridCell.Tab.0.right/0.0.1920.1080@0.0.1920.1080" timestamp="1617033424354" />
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1616326478876">
|
<state width="1879" height="364" key="GridCell.Tab.1.bottom" timestamp="1616326478876">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
@ -129,12 +129,12 @@
|
|||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616326478875" />
|
<state width="1879" height="364" key="GridCell.Tab.1.right/0.0.1920.1080@0.0.1920.1080" timestamp="1616326478875" />
|
||||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1616874983207">
|
<state x="0" y="0" key="com.intellij.ide.util.TipDialog" timestamp="1617029024880">
|
||||||
<screen x="0" y="0" width="1920" height="1080" />
|
<screen x="0" y="0" width="1920" height="1080" />
|
||||||
</state>
|
</state>
|
||||||
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1616874983207" />
|
<state x="0" y="0" key="com.intellij.ide.util.TipDialog/0.0.1920.1080@0.0.1920.1080" timestamp="1617029024880" />
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||||
<SUITE FILE_PATH="coverage/SmartTractor$py.coverage" NAME="py Coverage Results" MODIFIED="1616876630669" 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="1617033003775" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,7 +13,9 @@ WIN = pygame.display.set_mode((WIDTH, HEIGHT))
|
|||||||
TRACTOR = pygame.image.load(os.path.join('resources', 'tractor.png'))
|
TRACTOR = pygame.image.load(os.path.join('resources', 'tractor.png'))
|
||||||
TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE))
|
TRACTOR = pygame.transform.scale(TRACTOR, (BLOCK_SIZE, BLOCK_SIZE))
|
||||||
TRACTOR_FERTILIZER = 2
|
TRACTOR_FERTILIZER = 2
|
||||||
WHEAT_GROW_TIME = 5
|
TRACTOR_FUEL = 5
|
||||||
|
TRACTOR_WATER_LEVEL = 3
|
||||||
|
WHEAT_GROW_TIME = 50
|
||||||
WHEAT_MAXIMUM_STATE = 21
|
WHEAT_MAXIMUM_STATE = 21
|
||||||
WHEATSTAGE1 = pygame.image.load(os.path.join('resources', 'wheat_stage1.png'))
|
WHEATSTAGE1 = pygame.image.load(os.path.join('resources', 'wheat_stage1.png'))
|
||||||
WHEATSTAGE1 = pygame.transform.scale(WHEATSTAGE1, (BLOCK_SIZE, BLOCK_SIZE))
|
WHEATSTAGE1 = pygame.transform.scale(WHEATSTAGE1, (BLOCK_SIZE, BLOCK_SIZE))
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
class Fertilizer:
|
|
||||||
def __init__(self, name):
|
|
||||||
self.name = name
|
|
||||||
def get_name(self):
|
|
||||||
return self.name
|
|
||||||
def set_name(self, name):
|
|
||||||
self.name = name
|
|
20
py.py
20
py.py
@ -39,17 +39,21 @@ def fill_map():
|
|||||||
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is True:
|
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is True:
|
||||||
block = definitions.FARMLANDMOIST
|
block = definitions.FARMLANDMOIST
|
||||||
definitions.WIN.blit(block, (rect.x, rect.y))
|
definitions.WIN.blit(block, (rect.x, rect.y))
|
||||||
def do_work(tractor1_rect):
|
def do_work(tractor1, tractor1_rect):
|
||||||
x = int(tractor1_rect.x/100)
|
x = int(tractor1_rect.x/100)
|
||||||
y = int(tractor1_rect.y/100)
|
y = int(tractor1_rect.y/100)
|
||||||
field = fields[x][y]
|
field = fields[x][y]
|
||||||
if field.get_soil().get_state() is False:
|
if field.get_soil().get_state() is False:
|
||||||
field.get_soil().set_state(True)
|
field.get_soil().set_state(True)
|
||||||
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is False:
|
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is False and tractor1.get_water_level() > 0:
|
||||||
|
tractor1.set_water_level(tractor1.get_water_level() - 1)
|
||||||
field.get_soil().set_water_level(True)
|
field.get_soil().set_water_level(True)
|
||||||
elif field.get_plant().get_state() == 0:
|
elif field.get_soil().get_state() is True and field.get_soil().get_water_level() is True and field.get_plant().get_state() == 0:
|
||||||
field.get_plant().set_name("wheat")
|
field.get_plant().set_name("wheat")
|
||||||
field.get_plant().set_state(1)
|
field.get_plant().set_state(1)
|
||||||
|
elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() > 0 and field.get_plant().get_state() < definitions.WHEAT_MAXIMUM_STATE - definitions.WHEAT_GROW_TIME and tractor1.get_fertilizer("wheat") > 0:
|
||||||
|
tractor1.set_fertilizer("wheat", (tractor1.get_fertilizer("wheat") - 1))
|
||||||
|
field.get_plant().set_state(field.get_plant().get_state() + definitions.WHEAT_GROW_TIME)
|
||||||
elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() == definitions.WHEAT_MAXIMUM_STATE:
|
elif field.get_plant().get_name() == "wheat" and field.get_plant().get_state() == definitions.WHEAT_MAXIMUM_STATE:
|
||||||
field.get_plant().set_state(0)
|
field.get_plant().set_state(0)
|
||||||
field.get_soil().set_water_level(False)
|
field.get_soil().set_water_level(False)
|
||||||
@ -77,7 +81,7 @@ def is_move_allowed(move, tractor1_rect):
|
|||||||
return False
|
return False
|
||||||
def tractor1_handle_movement(tractor1, tractor1_rect):
|
def tractor1_handle_movement(tractor1, tractor1_rect):
|
||||||
loop = True
|
loop = True
|
||||||
while loop:
|
while loop and tractor1.get_fuel() > 0:
|
||||||
random1 = random.randint(1, 4)
|
random1 = random.randint(1, 4)
|
||||||
if ((random1 == 1) and (is_move_allowed(1, tractor1_rect) is True)):
|
if ((random1 == 1) and (is_move_allowed(1, tractor1_rect) is True)):
|
||||||
tractor1.move_down()
|
tractor1.move_down()
|
||||||
@ -99,10 +103,14 @@ def tractor1_handle_movement(tractor1, tractor1_rect):
|
|||||||
tractor1_rect.x = tractor1.get_x()
|
tractor1_rect.x = tractor1.get_x()
|
||||||
tractor1_rect.y = tractor1.get_y()
|
tractor1_rect.y = tractor1.get_y()
|
||||||
loop = False
|
loop = False
|
||||||
|
tractor1.set_fuel(tractor1.get_fuel() - 1)
|
||||||
|
if tractor1_rect.x == 0 and tractor1_rect.y == 0:
|
||||||
|
tractor1.set_fuel(definitions.TRACTOR_FUEL)
|
||||||
|
tractor1.set_water_level(definitions.TRACTOR_WATER_LEVEL)
|
||||||
def main():
|
def main():
|
||||||
create_base_map()
|
create_base_map()
|
||||||
fertilizer_dict = {"beetroot": definitions.TRACTOR_FERTILIZER, "carrot": definitions.TRACTOR_FERTILIZER, "potato": definitions.TRACTOR_FERTILIZER, "wheat": definitions.TRACTOR_FERTILIZER}
|
fertilizer_dict = {"beetroot": definitions.TRACTOR_FERTILIZER, "carrot": definitions.TRACTOR_FERTILIZER, "potato": definitions.TRACTOR_FERTILIZER, "wheat": definitions.TRACTOR_FERTILIZER}
|
||||||
tractor1 = tractor.Tractor(fertilizer_dict, 0, 0)
|
tractor1 = tractor.Tractor(fertilizer_dict, definitions.TRACTOR_FUEL, definitions.TRACTOR_WATER_LEVEL ,0, 0)
|
||||||
tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
|
tractor1_rect = pygame.Rect(tractor1.get_x(), tractor1.get_y(), definitions.BLOCK_SIZE, definitions.BLOCK_SIZE)
|
||||||
clock = pygame.time.Clock()
|
clock = pygame.time.Clock()
|
||||||
run = True
|
run = True
|
||||||
@ -114,7 +122,7 @@ def main():
|
|||||||
draw_window(tractor1_rect)
|
draw_window(tractor1_rect)
|
||||||
grow_plants()
|
grow_plants()
|
||||||
tractor1_handle_movement(tractor1, tractor1_rect)
|
tractor1_handle_movement(tractor1, tractor1_rect)
|
||||||
do_work(tractor1_rect)
|
do_work(tractor1, tractor1_rect)
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
7
station.py
Normal file
7
station.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class Station:
|
||||||
|
def __init__(self, collected_plants):
|
||||||
|
self.collected_plants = collected_plants
|
||||||
|
def get_collected_plants(self, name):
|
||||||
|
return self.collected_plants[name]
|
||||||
|
def set_collected_plants(self, name, value):
|
||||||
|
self.collected_plants[name] = value
|
20
tractor.py
20
tractor.py
@ -1,13 +1,23 @@
|
|||||||
import definitions
|
import definitions
|
||||||
class Tractor:
|
class Tractor:
|
||||||
def __init__(self, fertilizer, x, y):
|
def __init__(self, fertilizer, fuel, water_level, x, y):
|
||||||
self.fertilizer = fertilizer
|
self.fertilizer = fertilizer
|
||||||
|
self.fuel = fuel
|
||||||
|
self.water_level = water_level
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
def get_fertilizer(self):
|
def get_fertilizer(self, name):
|
||||||
return self.fertilizer
|
return self.fertilizer[name]
|
||||||
def set_fertilizer(self, fertilizer):
|
def set_fertilizer(self, name, value):
|
||||||
self.fertilizer = fertilizer
|
self.fertilizer[name] = value
|
||||||
|
def get_fuel(self):
|
||||||
|
return self.fuel
|
||||||
|
def set_fuel(self, fuel):
|
||||||
|
self.fuel = fuel
|
||||||
|
def get_water_level(self):
|
||||||
|
return self.water_level
|
||||||
|
def set_water_level(self, water_level):
|
||||||
|
self.water_level = water_level
|
||||||
def get_x(self):
|
def get_x(self):
|
||||||
return self.x
|
return self.x
|
||||||
def set_x(self, x):
|
def set_x(self, x):
|
||||||
|
Loading…
Reference in New Issue
Block a user