"""
Weather functions.
"""
from ursina import color, window, time
from nMap import nMap

class Weather:
    def __init__(this, rate=1):
        this.red = 0
        this.green = 200
        this.blue = 211

        this.darkling = 0

        this.rate = rate

        this.towardsNight = 1

    def setSky(this):
        r = nMap(this.darkling,0,100,0,this.red)
        g = nMap(this.darkling,0,100,0,this.green)
        b = nMap(this.darkling,0,100,0,this.blue)
        window.color = color.rgb(r,g,b)

    def update(this):
        this.darkling -= (  this.rate * 
                            this.towardsNight *
                            time.dt)
        if this.darkling < 0:
            this.towardsNight *= -1
            this.darkling = 0
        
        this.setSky()

[((20, 12, 20, 48), 'nMap.nMap', 'nMap', ({(20, 17, 20, 30): 'this.darkling', (20, 31, 20, 32): '0', (20, 33, 20, 36): '100', (20, 37, 20, 38): '0', (20, 39, 20, 47): 'this.red'}, {}), '(this.darkling, 0, 100, 0, this.red)', False, 'from nMap import nMap\n'), ((21, 12, 21, 50), 'nMap.nMap', 'nMap', ({(21, 17, 21, 30): 'this.darkling', (21, 31, 21, 32): '0', (21, 33, 21, 36): '100', (21, 37, 21, 38): '0', (21, 39, 21, 49): 'this.green'}, {}), '(this.darkling, 0, 100, 0, this.green)', False, 'from nMap import nMap\n'), ((22, 12, 22, 49), 'nMap.nMap', 'nMap', ({(22, 17, 22, 30): 'this.darkling', (22, 31, 22, 32): '0', (22, 33, 22, 36): '100', (22, 37, 22, 38): '0', (22, 39, 22, 48): 'this.blue'}, {}), '(this.darkling, 0, 100, 0, this.blue)', False, 'from nMap import nMap\n'), ((23, 23, 23, 39), 'ursina.color.rgb', 'color.rgb', ({(23, 33, 23, 34): 'r', (23, 35, 23, 36): 'g', (23, 37, 23, 38): 'b'}, {}), '(r, g, b)', False, 'from ursina import color, window, time\n')]