AI_PROJECT/Condition.py

48 lines
1.5 KiB
Python

import random
import Climate
import Ui
class Condition:
def __init__(self):
self.season=self.setRandomSeason()
self.currentTime=self.setRandomTime()
self.rain=self.setRandomRain()
self.temperature=self.setRandomRain()
self.clock=0
def setRandomSeason(self):
return self.randomizer(Climate.getAmount("seasons"))
def setRandomTime(self):
return self.randomizer(Climate.getAmount("time"))
def setRandomRain(self):
return self.randomizer(Climate.getAmount("rain"))
def setRandomTemperature(self):
return self.randomizer(Climate.getAmount("temperature"))
def randomizer(self,max):
return random.randint(0,max-1)
def cycle(self):
if(self.clock==12):
self.currentTime=0
self.rain=self.setRandomRain()
self.temperature=self.setRandomTemperature()
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()
self.clock=self.clock+1
def return_condition(self):
return [self.temperature,self.rain,self.season,self.currentTime]
def getCondition(self):
print(f"Aktualny czas: {Climate.time[self.currentTime]},opady: {Climate.rain[self.rain]},temperatura: {Climate.temperature[self.temperature]}, pora roku: {Climate.seasons[self.season]}")