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

    this.getDescription = function()
    {
        return qsTr("An extremely rare and violent storm Category 5. Severely cripples naval, coastal units, and increase movement cost +3 to air, helicopter and drone operations.");
    };

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

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

    this.getMovementCostModifier = function(weather, unit, terrain, map)
    {
        var uType = unit.getUnitType();
        if (uType === GameEnums.UnitType_Air || 
            uType === GameEnums.REMOTE_WEAPON || 
            uType === GameEnums.HELICOPTER || 
            uType === GameEnums.DRONE)
        {
            return 3;
        }
        return 0;
    };

	this.getVisionrangeModifier = function()
	{

	    return -2;
	};
	
    this.onStartOfTurn = function(weather, unit, map)
    {
        var uType = unit.getUnitType();
        if (uType === GameEnums.UnitType_Naval || uType === GameEnums.COASTAL)
        {
            if (!unit.getWeatherImmune())
            {
                if (unit.getOwner() === map.getCurrentPlayer())
                {
                    unit.setHp(unit.getHp() - 2);
                    
                    if (unit.getHp() <= 0)
                    {
                        unit.killUnit();
                    }
                }
            }
        }
    };

    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", "#80101040", 3000, true);
        
        animation.setSound("hurricane.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_HURRICANE = new Constructor();