AI_PROJECT/Condition.py

48 lines
1.5 KiB
Python
Raw Normal View History

2024-05-10 18:33:38 +02:00
import random
import Climate
import Ui
2024-05-10 18:33:38 +02:00
class Condition:
def __init__(self):
self.season=self.setRandomSeason()
self.currentTime=self.setRandomTime()
self.rain=self.setRandomRain()
self.temperature=self.setRandomRain()
2024-05-10 18:33:38 +02:00
self.clock=0
def setRandomSeason(self):
return self.randomizer(Climate.getAmount("seasons"))
2024-05-10 18:33:38 +02:00
def setRandomTime(self):
return self.randomizer(Climate.getAmount("time"))
2024-05-10 18:33:38 +02:00
def setRandomRain(self):
return self.randomizer(Climate.getAmount("rain"))
2024-05-10 18:33:38 +02:00
def setRandomTemperature(self):
return self.randomizer(Climate.getAmount("temperature"))
2024-05-10 18:33:38 +02:00
def randomizer(self,max):
return random.randint(0,max-1)
2024-05-10 18:33:38 +02:00
def cycle(self):
if(self.clock==11):
self.currentTime=0
self.rain=self.setRandomRain()
self.temperature=self.setRandomTemperature()
2024-05-10 18:33:38 +02:00
self.season=Climate.getNextSeason(self.season)
self.clock=0
return
else:
self.currentTime=Climate.getNextTime(self.currentTime)
self.rain=self.setRandomRain()
self.temperature=self.setRandomTemperature()
2024-05-10 18:33:38 +02:00
self.clock=self.clock+1
def return_condition(self):
return [self.temperature,self.rain,self.season,self.currentTime]
2024-05-10 18:33:38 +02:00
def getCondition(self):
return ([Climate.temperature[self.temperature],Climate.rain[self.rain],Climate.seasons[self.season],Climate.time[self.currentTime]])