cyphesis/rulesets/deeds/world/objects/Weather.py
Erik Ogenvik 2dca4949ed Created "deeds" ruleset and made it default.
It's currently a copy of the Mason ruleset.
Where Mason focuses on letting the users create the world themselves,
Deeds instead focuses on allowing world authors to set up enticing
worlds with gameplay and stories. In contrast to Mason there are more
features available to the world authors which allow for automatic
creation of entities and so on.
2013-11-15 21:14:47 +01:00

28 lines
1 KiB
Python

#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 *
from common import log,const
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
if self.rain<0.1:
optick.setFutureSeconds(randint(60,300))
self.rain=uniform(0.1, 0.9)
self.visibility=10/(self.rain * self.rain)
res = res + Operation("set", Entity(world.id, moisture=1), to=world)
else:
moisture = world.moisture
optick.setFutureSeconds(randint(600,2400))
self.rain=0.0
self.visibility=1000
res = res + Operation("set", Entity(world.id, moisture=moisture-0.5), to=world)
res = res+Operation("set", Entity(self.id,rain=self.rain,visibility=self.visibility), to=self)
return res