2024-05-10 18:33:38 +02:00
|
|
|
import random
|
|
|
|
import Climate
|
|
|
|
|
|
|
|
class Condition:
|
|
|
|
def __init__(self):
|
|
|
|
self.season=self.setRandomSeason()
|
|
|
|
self.currentTime=self.setRandomTime()
|
2024-05-11 13:24:09 +02:00
|
|
|
self.rain=self.setRandomRain()
|
|
|
|
self.temperature=self.setRandomRain()
|
2024-05-10 18:33:38 +02:00
|
|
|
self.clock=0
|
|
|
|
|
|
|
|
def setRandomSeason(self):
|
2024-05-11 13:24:09 +02:00
|
|
|
return self.randomizer(Climate.getAmount("seasons"))
|
2024-05-10 18:33:38 +02:00
|
|
|
|
|
|
|
def setRandomTime(self):
|
2024-05-11 13:24:09 +02:00
|
|
|
return self.randomizer(Climate.getAmount("time"))
|
2024-05-10 18:33:38 +02:00
|
|
|
|
2024-05-11 13:24:09 +02:00
|
|
|
def setRandomRain(self):
|
|
|
|
return self.randomizer(Climate.getAmount("rain"))
|
2024-05-10 18:33:38 +02:00
|
|
|
|
2024-05-11 13:24:09 +02:00
|
|
|
def setRandomTemperature(self):
|
|
|
|
return self.randomizer(Climate.getAmount("temperature"))
|
2024-05-10 18:33:38 +02:00
|
|
|
|
2024-05-11 13:24:09 +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==12):
|
2024-05-11 13:24:09 +02:00
|
|
|
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)
|
2024-05-11 13:24:09 +02:00
|
|
|
self.rain=self.setRandomRain()
|
|
|
|
self.temperature=self.setRandomTemperature()
|
2024-05-10 18:33:38 +02:00
|
|
|
self.clock=self.clock+1
|
|
|
|
|
|
|
|
def getCondition(self):
|
2024-05-11 13:24:09 +02:00
|
|
|
print(f"Aktualny czas: {Climate.time[self.currentTime]},opady: {Climate.rain[self.rain]},temperatura: {Climate.temperature[self.temperature]}, pora roku: {Climate.seasons[self.season]}")
|
2024-05-10 18:33:38 +02:00
|
|
|
|