Added some crop protection products to tractor and finished some of its functions

This commit is contained in:
JakubStac 2024-03-23 22:54:51 +01:00
parent 679b8ca1b8
commit 6e3e042a93
3 changed files with 44 additions and 12 deletions

View File

@ -1,24 +1,56 @@
from crop_protection_product import CropProtectionProduct
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")
# etc
def __init__(self, x, y):
self.x = x
self.y = y
self.image = 'resources/images/tractor.png'
def work_on_field(self, ground, plant):
if plant is None:
pass # zasadz cos
if ground.pest == True:
def work_on_field(self, tile, ground, plant1):
if plant1 is None:
tile.randomizeContent()
# sprobuj zasadzic cos
elif plant1.growth_level == 100:
tile.plant = None
ground.nutrients -= 40
ground.water -= 40
else:
plant1.try_to_grow()
ground.nutrients -= 11
ground.water -= 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 == True:
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
if ground.water < plant.water_requirements:
if ground.water < plant1.water_requirements:
ground.water += 20
if ground.nutrients < plant.nutrients_requirements:
if ground.nutrients < plant1.nutrients_requirements:
ground.nutrients += 20

View File

@ -1,3 +1,4 @@
class CropProtectionProduct:
def __init__(self, strong_against):
def __init__(self, strong_against, plant_type):
self.strong_against = strong_against # pestycyd, herbicyd
self.plant_type = plant_type

View File

@ -35,7 +35,7 @@ class Tile:
def randomizeContent(self):
photo_path = self.randomize_photo()
i = random.randint(1, 3) #szansa 1/3
i = random.randint(1, 3) # szansa 1/3
if i == 1:
self.image = "resources/images/sampling.png"
self.photo = photo_path
@ -44,5 +44,4 @@ class Tile:
self.image = "resources/images/dirt.png"
self.photo = "resources/images/background.jpg"
# DISCLAMER check column and choose plant type ("potato","wheat" etc)
# DISCLAMER check column and choose plant type ("potato","wheat" etc.)