private void SetTomorrowWeather() { //if tomorrow is a festival or wedding, we need to set the weather and leave. if (Utility.isFestivalDay(Game1.dayOfMonth + 1, Game1.currentSeason)) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_festival; Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"Festival tomorrow. Aborting processing.", LogLevel.Trace); } //if (WeatherOpt.Verbose) Monitor.Log(DebugOutput.ToString()); return; } if (Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1) { Game1.netWorldState.Value.WeatherForTomorrow = Game1.weatherForTomorrow = Game1.weather_wedding; Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"Wedding tomorrow. Aborting processing.", LogLevel.Trace); } return; } if (WeatherUtilities.CheckForForceDay(DescriptionEngine, SDate.Now().AddDays(1), Monitor, WeatherOpt.Verbose)) { Conditions.HaltWeatherSystem(); if (WeatherOpt.Verbose) { Monitor.Log($"The game will force tomorrow. Aborting processing.", LogLevel.Trace); } return; } if (WeatherOpt.Verbose) { Monitor.Log("Setting weather for tomorrow"); } //now set tomorrow's weather var OddsForTheDay = GameClimate.GetClimateForDate(SDate.Now().AddDays(1)); //get system odds double rainSystem = OddsForTheDay.RetrieveSystemOdds("rain"); double windSystem = OddsForTheDay.RetrieveSystemOdds("debris"); double sunSystem = OddsForTheDay.RetrieveSystemOdds("sunny"); if (!Game1.player.mailReceived.Contains("ccDoorUnlock")) { rainSystem = Math.Max(rainSystem - .1, 0); windSystem = Math.Max(windSystem - .1, 0); sunSystem = Math.Min(sunSystem + .2, 1); } //get loose odds double rainDays = OddsForTheDay.RetrieveOdds(Dice, "rain", SDate.Now().AddDays(1).Day); double windyDays = OddsForTheDay.RetrieveOdds(Dice, "debris", SDate.Now().AddDays(1).Day); double stormDays = OddsForTheDay.RetrieveOdds(Dice, "storm", SDate.Now().AddDays(1).Day); if (!Game1.player.mailReceived.Contains("ccDoorUnlock")) { rainDays = Math.Max(rainDays - .1, 0); windyDays = Math.Max(windyDays - .1, 0); } if (WeatherOpt.Verbose) { Monitor.Log($"Weather Odds are Rain: {rainDays:N3}, Windy: {windyDays:N3}, and Storm {stormDays:N3}"); Monitor.Log($"Weather System Odds are Rain: {rainSystem:N3}, Windy: {windSystem:N3}, and Storm {sunSystem:N3}"); } //set tomorrow's weather if (Conditions.trackerModel.IsWeatherSystem) { double SystemContinuesOdds = WeatherProcessing.GetWeatherSystemOddsForNewDay(Conditions); if (WeatherOpt.Verbose) { Monitor.Log($"Rolling system odds against {SystemContinuesOdds:N3}"); } if (Dice.NextDouble() < SystemContinuesOdds) { if (WeatherOpt.Verbose) { Monitor.Log($"Continuing system odds - now for {Conditions.trackerModel.WeatherSystemDays + 1} for weather {Conditions.trackerModel.WeatherSystemType}"); } Conditions.trackerModel.WeatherSystemDays++; WeatherProcessing.SetWeatherTomorrow(Conditions.trackerModel.WeatherSystemType, Dice, GameClimate, stormDays, Conditions.GetTomorrowTemps()); } else { if (WeatherOpt.Verbose) { Monitor.Log($"Ending system, new weather type."); } Conditions.trackerModel.IsWeatherSystem = false; WeatherProcessing.SetWeatherNonSystemForTomorrow(Dice, GameClimate, rainDays, stormDays, windyDays, Conditions.GetTomorrowTemps()); } } else { if (Dice.NextDouble() < WeatherOpt.WeatherSystemChance) { if (WeatherOpt.Verbose) { Monitor.Log($"Rolling system odds against {WeatherOpt.WeatherSystemChance:N3}, created system."); } ProbabilityDistribution <string> SystemDist = new ProbabilityDistribution <string>(); SystemDist.AddNewCappedEndPoint(rainSystem, "rain"); SystemDist.AddNewCappedEndPoint(windSystem, "debris"); SystemDist.AddNewCappedEndPoint(sunSystem, "sunny"); double distOdd = Dice.NextDouble(); if (!(SystemDist.GetEntryFromProb(distOdd, out string Result))) { Result = "sunny"; Monitor.Log("The weather has failed to process in some manner. Falling back to [sunny]", LogLevel.Info); } Conditions.SetNewWeatherSystem(Result, 1); WeatherProcessing.SetWeatherTomorrow(Result, Dice, GameClimate, stormDays, Conditions.GetTomorrowTemps()); } else { WeatherProcessing.SetWeatherNonSystemForTomorrow(Dice, GameClimate, rainDays, stormDays, windyDays, Conditions.GetTomorrowTemps()); } } }