Beispiel #1
0
        internal static bool TestForSpecialWeather(WeatherConditions curr, FerngillClimateTimeSpan ClimateForDay)
        {
            bool specialWeatherTriggered = false;

            // Conditions: Blizzard - occurs in weather_snow in "winter"
            //             Dry Lightning - occurs if it's sunny in any season if temps exceed 25C.
            //             Frost and Heatwave check against the configuration.
            //             Thundersnow  - as Blizzard, but really rare. Will not happen in fog, may happen in Blizzard/WhiteOut
            //             Sandstorm - windy, with no precip for several days. Spring-Fall only, highest chance in summer.
            //             Fog - per climate, although night fog in winter is double normal chance
            curr.GenerateEveningFog = (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.EveningFogChance * ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth)) && !curr.GetCurrentConditions().HasFlag(CurrentWeather.Wind);

            bool blockFog = ClimatesOfFerngill.MoonAPI != null && ClimatesOfFerngill.MoonAPI.IsSolarEclipse();

            if (blockFog || ClimatesOfFerngill.WeatherOpt.DisableAllFog)
            {
                curr.GenerateEveningFog = false;
            }

            double fogRoll = (ClimatesOfFerngill.WeatherOpt.DisableAllFog ? 1.1 : ClimatesOfFerngill.Dice.NextDoublePositive());

            if (fogRoll < ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth) && !curr.GetCurrentConditions().HasFlag(CurrentWeather.Wind) && !blockFog)
            {
                curr.CreateWeather("Fog");

                if (ClimatesOfFerngill.WeatherOpt.Verbose)
                {
                    ClimatesOfFerngill.Logger.Log($"{curr.FogDescription(fogRoll, ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "fog", Game1.dayOfMonth))}");
                }

                specialWeatherTriggered = true;
            }

            //set special temps before we check for the results of them
            if (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.HeatwaveChance)
            {
                SetHotwave();
            }
            else if (ClimatesOfFerngill.Dice.NextDouble() < ClimateForDay.ChillwaveChance)
            {
                SetChillWave();
            }

            //do these here
            //20190626 - Thanks to Crops Anywhere, I have to add this
            if ((curr.TodayLow < ClimatesOfFerngill.WeatherOpt.TooColdOutside && !Game1.IsWinter) || (curr.TodayLow < ClimatesOfFerngill.WeatherOpt.TooColdOutside && Game1.IsWinter &&
                                                                                                      ClimatesOfFerngill.WeatherOpt.ApplyFrostsInWinter))
            {
                if (ClimatesOfFerngill.WeatherOpt.HazardousWeather)
                {
                    curr.AddWeather(CurrentWeather.Frost);
                    specialWeatherTriggered = true;
                }
            }

            //test for spring conversion
            if (curr.HasWeather(CurrentWeather.Rain) && curr.HasWeather(CurrentWeather.Frost) && (Game1.currentSeason == "spring" || Game1.currentSeason == "fall") &&
                ClimatesOfFerngill.Dice.NextDoublePositive() <= ClimatesOfFerngill.WeatherOpt.RainToSnowConversion)
            {
                curr.RemoveWeather(CurrentWeather.Rain);
                curr.AddWeather(CurrentWeather.Snow);
                Game1.isRaining         = false;
                Game1.isSnowing         = true;
                specialWeatherTriggered = true;
            }


            if (curr.HasWeather(CurrentWeather.Snow))
            {
                double blizRoll = ClimatesOfFerngill.Dice.NextDoublePositive();
                double blizOdds = ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "blizzard", Game1.dayOfMonth);
                if (blizRoll <= blizOdds)
                {
                    curr.CreateWeather("Blizzard");
                    if (ClimatesOfFerngill.WeatherOpt.Verbose)
                    {
                        ClimatesOfFerngill.Logger.Log($"With roll {blizRoll:N3} against {blizOdds}, there will be blizzards today");
                    }
                    if (ClimatesOfFerngill.Dice.NextDoublePositive() < ClimatesOfFerngill.WeatherOpt.WhiteOutChances && ClimatesOfFerngill.WeatherOpt.HazardousWeather)
                    {
                        curr.CreateWeather("WhiteOut");
                    }
                }

                specialWeatherTriggered = true;
            }

            //Dry Lightning is also here for such like the dry and arid climates
            //  which have so low rain chances they may never storm.
            if (curr.HasWeather(CurrentWeather.Snow))
            {
                double oddsRoll        = ClimatesOfFerngill.Dice.NextDoublePositive();
                double thunderSnowOdds = ClimateForDay.RetrieveOdds(ClimatesOfFerngill.Dice, "storm", Game1.dayOfMonth);

                if (oddsRoll <= thunderSnowOdds && !curr.HasWeather(CurrentWeather.Fog))
                {
                    curr.AddWeather(CurrentWeather.Lightning);
                    if (ClimatesOfFerngill.WeatherOpt.Verbose)
                    {
                        ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {thunderSnowOdds}, there will be thundersnow today");
                    }

                    specialWeatherTriggered = true;
                }
            }

            if (!(curr.HasPrecip()))
            {
                double oddsRoll = ClimatesOfFerngill.Dice.NextDoublePositive();

                if (oddsRoll <= ClimatesOfFerngill.WeatherOpt.DryLightning && curr.TodayHigh >= ClimatesOfFerngill.WeatherOpt.DryLightningMinTemp &&
                    !curr.HasWeather(CurrentWeather.Frost))
                {
                    curr.AddWeather(CurrentWeather.Lightning);
                    if (ClimatesOfFerngill.WeatherOpt.Verbose)
                    {
                        ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {ClimatesOfFerngill.WeatherOpt.DryLightning}, there will be dry lightning today.");
                    }

                    specialWeatherTriggered = true;
                }

                if (curr.TodayHigh > ClimatesOfFerngill.WeatherOpt.TooHotOutside && ClimatesOfFerngill.WeatherOpt.HazardousWeather)
                {
                    curr.AddWeather(CurrentWeather.Heatwave);
                    specialWeatherTriggered = true;
                }

                double sandstormOdds = .18;
                if (Game1.currentSeason == "summer")
                {
                    sandstormOdds *= 1.2;
                }

                if (oddsRoll < sandstormOdds && ClimatesOfFerngill.WeatherOpt.HazardousWeather && Game1.isDebrisWeather)
                {
                    curr.AddWeather(CurrentWeather.Sandstorm);
                    specialWeatherTriggered = true;
                    curr.CreateWeather("Sandstorm");
                }
            }

            //and finally, test for thunder frenzy
            if (curr.HasWeather(CurrentWeather.Lightning) && curr.HasWeather(CurrentWeather.Rain) && ClimatesOfFerngill.WeatherOpt.HazardousWeather)
            {
                double oddsRoll = ClimatesOfFerngill.Dice.NextDouble();
                if (oddsRoll < ClimatesOfFerngill.WeatherOpt.ThunderFrenzyOdds)
                {
                    curr.AddWeather(CurrentWeather.ThunderFrenzy);
                    specialWeatherTriggered = true;
                    if (ClimatesOfFerngill.WeatherOpt.Verbose)
                    {
                        ClimatesOfFerngill.Logger.Log($"With roll {oddsRoll:N3} against {ClimatesOfFerngill.WeatherOpt.ThunderFrenzyOdds}, there will be a thunder frenzy today");
                    }
                    curr.CreateWeather("ThunderFrenzy");
                }
            }

            return(specialWeatherTriggered);
        }