Traktor/source/area/tractor.py

61 lines
2.4 KiB
Python
Raw Normal View History

from crop_protection_product import CropProtectionProduct
2024-03-07 18:01:12 +01:00
class Tractor:
x = None
y = None
image = None
cypermetryna = CropProtectionProduct("pests", "cereal")
diflufenikan = CropProtectionProduct("weeds", "cereal")
spirotetramat = CropProtectionProduct("pests", "fruit")
oksadiargyl = CropProtectionProduct("weeds", "fruit")
spinosad = CropProtectionProduct("pests", "vegetable")
metazachlor = CropProtectionProduct("weeds", "vegetable")
2024-03-07 18:01:12 +01:00
# etc
def __init__(self, x, y):
2024-03-07 18:01:12 +01:00
self.x = x
self.y = y
self.image = 'resources/images/tractor.png'
def work_on_field(self, tile, ground, plant1):
if plant1 is None:
tile.randomizeContent()
# sprobuj zasadzic cos
2024-03-25 01:02:03 +01:00
print("Tarctor planted something")
elif plant1.growth_level == 100:
tile.plant = None
2024-03-25 01:02:03 +01:00
ground.nutrients_level -= 40
ground.water_level -= 40
print("Tractor collected something")
else:
2024-03-25 01:02:03 +01:00
plant1.try_to_grow(50,50) #mozna dostosowac jeszcze
ground.nutrients_level -= 11
ground.water_level -= 11
if ground.pest:
# traktor pozbywa sie szkodnikow
if plant1.plant_type == self.cypermetryna.plant_type:
t = "Tractor used Cypermetryna"
elif plant1.plant_type == self.spirotetramat.plant_type:
t = "Tractor used Spirotetramat"
elif plant1.plant_type == self.spinosad.plant_type:
t = "Tractor used Spinosad"
print(t)
ground.pest = False
if ground.weed:
# traktor pozbywa się chwastow
if plant1.plant_type == self.diflufenikan.plant_type:
t = "Tractor used Diflufenikan"
elif plant1.plant_type == self.oksadiargyl.plant_type:
t = "Tractor used Oksadiargyl"
elif plant1.plant_type == self.metazachlor.plant_type:
t = "Tractor used Metazachlor"
print(t)
ground.weed = False
2024-03-25 01:02:03 +01:00
if ground.water_level < plant1.water_requirements:
ground.water_level += 20
print("Tractor watered the plant")
if ground.nutrients_level < plant1.nutrients_requirements:
ground.nutrients_level += 20
print("Tractor added some nutrients")