AI_PRO/TractorAction.py

40 lines
1.3 KiB
Python
Raw Normal View History

2021-03-29 13:06:57 +02:00
from Main import TractorLoad
2021-03-29 14:33:16 +02:00
from Main.TractorLoad import TillageUnit
2021-03-29 13:06:57 +02:00
2021-03-29 19:15:36 +02:00
def action(field, tractor):
2021-03-29 14:33:16 +02:00
if tractor.header and tractor.hitch == "Crop Trailer" and field.state == "toCut":
2021-03-29 13:06:57 +02:00
return "toPlow"
2021-03-29 19:15:36 +02:00
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Fertilizer" and field.state == "toFertilize":
2021-03-29 13:06:57 +02:00
return "toSeed"
2021-03-29 19:15:36 +02:00
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Seeds" and field.state == "toSeed":
2021-03-29 13:06:57 +02:00
return "toWater"
2021-03-29 19:15:36 +02:00
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Water" and field.state == "toWater":
2021-03-29 13:06:57 +02:00
return "toCut"
2021-03-29 19:15:36 +02:00
elif isinstance(tractor.hitch, TillageUnit) and tractor.hitch.load == "Nothing" and field.state == "toPlow":
2021-03-29 13:06:57 +02:00
return "toFertilize"
2021-03-29 19:15:36 +02:00
def chooseToolset(tractor, tillageUnit, set):
if set == 0:
tractor.hitch = tillageUnit
tractor.hitch.load = "Nothing"
if set == 1:
tractor.hitch = tillageUnit
tractor.hitch.load = "Fertilizer"
if set == 2:
tractor.hitch = tillageUnit
tractor.hitch.load = "Seeds"
if set == 3:
tractor.hitch = tillageUnit
tractor.hitch.load = "Water"
if set == 4:
tractor.header = True
tractor.hitch = "Crop Trailer"
return tractor, tillageUnit