add plant class and modify tractor class
This commit is contained in:
parent
de745275bf
commit
1d2610b23e
@ -5,7 +5,7 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.9 (ai-project)" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (ai-project)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
|
||||
</project>
|
39
src/plant.py
Normal file
39
src/plant.py
Normal file
@ -0,0 +1,39 @@
|
||||
class Plant:
|
||||
"""class representing plants"""
|
||||
|
||||
def __init__(self, species, tile):
|
||||
self.species = species
|
||||
self.tile = tile
|
||||
self.position = tile.position
|
||||
match species:
|
||||
case "potato":
|
||||
self.min_hydration = 60
|
||||
self.max_hydration = 80
|
||||
self.plant_protectant = "Altima 500SC"
|
||||
self.fertilizer = "mocznik.pl"
|
||||
case "tomato":
|
||||
self.min_hydration = 70
|
||||
self.max_hydration = 80
|
||||
self.plant_protectant = "do uzupełnienia"
|
||||
self.fertilizer = "do uzupełnienia"
|
||||
case "beetroot":
|
||||
self.min_hydration = 50
|
||||
self.max_hydration = 75
|
||||
self.plant_protectant = "do uzupełnienia"
|
||||
self.fertilizer = "do uzupełnienia"
|
||||
case "cucumber":
|
||||
self.min_hydration = 70
|
||||
self.max_hydration = 90
|
||||
self.plant_protectant = "do uzupełnienia"
|
||||
self.fertilizer = "do uzupełnienia"
|
||||
self.growth = 0 # value between 0 and 1
|
||||
self.wilted = False
|
||||
|
||||
def remove(self):
|
||||
self.tile.planted = False
|
||||
|
||||
def grow(self):
|
||||
return True
|
||||
# function growing plant during tick
|
||||
# using parameters of field tile to calculate growth
|
||||
# for example if tile is hydrated and fertilized it will grow faster
|
@ -7,3 +7,22 @@ class Tractor:
|
||||
self.addition = addition
|
||||
self.trajectory = trajectory
|
||||
|
||||
def hydrate(self, tile):
|
||||
if tile.hydration < tile.plant.min_hydration:
|
||||
tile.hydration = tile.plant.max_hydration
|
||||
|
||||
def collect(self, tile):
|
||||
if tile.plant.growth >= 0.75:
|
||||
tile.remove_plant()
|
||||
|
||||
def cut(self, tile):
|
||||
tile.remove_plant()
|
||||
|
||||
def plant(self, tile):
|
||||
if not tile.planted:
|
||||
tile.plant()
|
||||
|
||||
def fertilize(self, tile):
|
||||
if not tile.isfertilized:
|
||||
tile.isFertilized = True
|
||||
tile.fertilizer = tile.plant.fertilizer
|
||||
|
8
src/tractor_addons.py
Normal file
8
src/tractor_addons.py
Normal file
@ -0,0 +1,8 @@
|
||||
class Addon:
|
||||
"""class representing plants"""
|
||||
|
||||
def __init__(self, type, capacity, application):
|
||||
|
||||
self.type = type
|
||||
self.capacity = capacity
|
||||
self.application = application
|
Loading…
Reference in New Issue
Block a user