2013-11-15 21:14:47 +01:00
|
|
|
#This file is distributed under the terms of the GNU General Public license.
|
|
|
|
|
#Copyright (C) 1999 Al Riddoch (See the file COPYING for details).
|
|
|
|
|
|
|
|
|
|
from atlas import *
|
2017-05-28 16:32:17 +02:00
|
|
|
from common import log,const
|
2013-11-15 21:14:47 +01:00
|
|
|
from random import *
|
|
|
|
|
|
|
|
|
|
import server
|
|
|
|
|
|
|
|
|
|
class Weather(server.Thing):
|
|
|
|
|
def tick_operation(self, op):
|
|
|
|
|
world = self.location.parent
|
|
|
|
|
res = Oplist()
|
|
|
|
|
optick = Operation("tick", to=self)
|
|
|
|
|
res = res + optick
|
2018-05-12 00:42:43 +02:00
|
|
|
if self.props.rain<0.1:
|
2013-11-15 21:14:47 +01:00
|
|
|
optick.setFutureSeconds(randint(60,300))
|
|
|
|
|
self.rain=uniform(0.1, 0.9)
|
2018-05-12 00:42:43 +02:00
|
|
|
self.visibility=10/(self.props.rain * self.props.rain)
|
2013-11-15 21:14:47 +01:00
|
|
|
res = res + Operation("set", Entity(world.id, moisture=1), to=world)
|
|
|
|
|
else:
|
|
|
|
|
moisture = world.moisture
|
|
|
|
|
optick.setFutureSeconds(randint(600,2400))
|
2018-05-12 00:42:43 +02:00
|
|
|
self.props.rain=0.0
|
|
|
|
|
self.props.visibility=1000
|
2013-11-15 21:14:47 +01:00
|
|
|
res = res + Operation("set", Entity(world.id, moisture=moisture-0.5), to=world)
|
2018-05-12 00:42:43 +02:00
|
|
|
res = res+Operation("set", Entity(self.id,rain=self.props.rain,visibility=self.props.visibility), to=self)
|
2013-11-15 21:14:47 +01:00
|
|
|
return res
|