AI_PROJECT/Condition.py

38 lines
1.1 KiB
Python

import random
import Climate
class Condition:
def __init__(self):
self.season=self.setRandomSeason()
self.currentTime=self.setRandomTime()
self.weather=self.setRandomWeather()
self.clock=0
def setRandomSeason(self):
return Climate.seasons[self.randomizer(3)]
def setRandomTime(self):
return Climate.time[self.randomizer(3)]
def setRandomWeather(self):
return Climate.weather[self.randomizer(6)]
def randomizer(self,maxIndex):
return random.randint(0,maxIndex)
def cycle(self):
if(self.clock==12):
self.currentTime=Climate.time[0]
self.weather=self.setRandomWeather()
self.season=Climate.getNextSeason(self.season)
self.clock=0
return
else:
self.currentTime=Climate.getNextTime(self.currentTime)
self.weather=self.setRandomWeather()
self.clock=self.clock+1
def getCondition(self):
print(f"Aktualny czas: {self.currentTime},pogoda: {self.weather}, pora roku: {self.season}")