var Constructor = function()
{
    this.getWeatherName = function()
    {
        return qsTr("Blizzard");
    };

    this.getDescription = function()
    {
        return qsTr("Extreme winter storm. Drastically reduces vision -2, hinders movement +2 cost, and enforces Fog of War.");
    };

    this.getWeatherTerrainSprite = function()
    {
        return "blizzard";
    };

    this.getWeatherSymbol = function()
    {
        return "weather_symbol_blizzard";
    };

    this.getVisionrangeModifier = function()
    {
        return -2;
    };

    this.getMovementCostModifier = function(weather, unit, terrain, map)
    {
        var id = terrain.getID();
        if ((unit.getUnitType() === GameEnums.UnitType_Air) ||
            (id !== "STREET" &&
             id !== "STREET1" &&
             id !== "SNOW_STREET" &&
             id !== "BRIDGE" &&
             id !== "BRIDGE1" &&
             id !== "BRIDGE2" &&
             id !== "WASTE_PATH" &&
             id !== "DESERT_PATH" &&
             id !== "DESERT_PATH1" &&
             id !== "TELEPORTTILE" &&
            terrain.getBuilding() === null))
        {
            return 2;
        }
        return 0;
    };

    this.activate = function(weather, map)
    {
        var animationCount = GameAnimationFactory.getAnimationCount();
        var queueAnimation = null;
        if (animationCount > 0)
        {
            queueAnimation = GameAnimationFactory.getAnimation(animationCount - 1);
        }
        var animation = GameAnimationFactory.createAnimation(map, 0, 0);
        
        animation.addSprite2("white_pixel", 0, 0, 3200, map.getMapWidth(), map.getMapHeight());
        animation.addTweenColor(0, "#00FFFFFF", "#C0E0E0E0", 3000, true);
        
        animation.setSound("blizzard.wav"); 
        animation.setStartOfAnimationCall("ANIMATION", "preOnAnimationChangedAnimation");

        var variable = weather.getVariables().createVariable("FOGMODE");
        var fogMode = map.getGameRules().getFogMode();
        variable.writeDataInt32(fogMode);
        if (fogMode < GameEnums.Fog_OfWar)
        {
            map.getGameRules().setFogMode(GameEnums.Fog_OfWar);
        }
        
        if (queueAnimation !== null)
        {
            queueAnimation.queueAnimation(animation);
        }
    };

    this.deactivate = function(weather, map)
    {
        var variable = weather.getVariables().getVariable("FOGMODE");
        if (variable !== null)
        {
            var mode = variable.readDataInt32();
            map.getGameRules().setFogMode(mode);
        }
    };

    this.getDefaultWeatherChance = function()
    {
        return 0;
    };
}

Constructor.prototype = WEATHER;
var WEATHER_BLIZZARD = new Constructor();