Пример #1
0
        internal string GenerateTVForecast(WeatherConditions Current, MersenneTwister Dice, double fogOdds, string MoonPhase = "", bool IsMoonUp = false)
        {
            string ret = "";

            //opening string
            ret += Translator.Get("weather-tv.opening", new
            {
                location       = Translator.Get("fern-loc." + Dice.Next(12)),
                playerLocation = Translator.Get("weather-location.player." + Dice.Next(4))
            });

            //hazard warning
            if (MoonPhase == "Blood Moon" && IsMoonUp)
            {
                ret += Translator.Get("weather-tv.bloodmoon");
            }

            if (Current.WeatherIsHazardous())
            {
                string hazard = "", rainfallW = "", hazardT = "", hazardF;

                if (Current.HasWeather(CurrentWeather.Heatwave))
                {
                    hazardT = Translator.Get("weather-tv.hazard.hw");
                }
                if (Current.HasWeather(CurrentWeather.Frost))
                {
                    hazardT = Translator.Get("weather-tv.hazard.frost");
                }

                if (Current.HasWeather(CurrentWeather.Blizzard))
                {
                    hazard = Translator.Get("weather-tv.hazard.blizzard");
                }
                if (Current.HasWeather(CurrentWeather.WhiteOut))
                {
                    hazard = Translator.Get("weather-tv.hazard.whiteout");
                }
                if (Current.HasWeather(CurrentWeather.ThunderFrenzy))
                {
                    hazard = Translator.Get("weather-tv.hazard.thunderfrenzy");
                }
                if (Current.HasWeather(CurrentWeather.Sandstorm))
                {
                    hazard = Translator.Get("weather-tv.hazard.sandstorm");
                }
                if (WeatherUtilities.IsSevereRainFall(Current.AmtOfRainDrops))
                {
                    switch (WeatherUtilities.GetRainCategory(Current.AmtOfRainDrops))
                    {
                    case RainLevels.Severe:
                        hazard = Translator.Get("weather-tv.hazard.rainfall.severe");
                        break;

                    case RainLevels.Torrential:
                        hazard = Translator.Get("weather-tv.hazard.rainfall.torrential");
                        break;

                    case RainLevels.Typhoon:
                        hazard = Translator.Get("weather-tv.hazard.rainfall.typhoon");
                        break;

                    case RainLevels.NoahsFlood:
                        hazard = Translator.Get("weather-tv.hazard.rainfall.noahsflood");
                        break;

                    default:
                        hazard = Translator.Get("weather-tv.hazard.rainfall.severe");
                        break;
                    }

                    rainfallW = Translator.Get("weather-tv.hazard.rainfallW");
                }

                if (!String.IsNullOrEmpty(hazard) && !String.IsNullOrEmpty(hazardT))
                {
                    hazardF = Translator.Get("weather-tv.twoHazardString", new { hazardOne = hazard, hazardTwo = hazardT });
                }
                else if (!String.IsNullOrEmpty(hazard))
                {
                    hazardF = hazard;
                }
                else
                {
                    hazardF = hazardT;
                }

                ret += Translator.Get("weather-tv.hazard", new {
                    hazard          = hazardF,
                    repLocation     = Translator.Get("weather-location.reporter." + Dice.Next(4)),
                    rainfallWarning = rainfallW
                });
            }

            //current conditions
            string time;

            switch (SDVTime.CurrentTimePeriod)
            {
            case SDVTimePeriods.Morning:
                time = Translator.Get("weather-tv.time.morning");
                break;

            case SDVTimePeriods.Noon:
            case SDVTimePeriods.Afternoon:
                time = Translator.Get("weather-tv.time.afternoon");
                break;

            case SDVTimePeriods.Evening:
                time = Translator.Get("weather-tv.time.evening");
                break;

            case SDVTimePeriods.Night:
                time = Translator.Get("weather-tv.time.night");
                break;

            case SDVTimePeriods.Midnight:
            case SDVTimePeriods.LateNight:
                time = Translator.Get("weather-tv.time.latenight");
                break;

            default:
                time = Translator.Get("weather-tv.time.generic");
                break;
            }

            string abText = "";

            if (Current.IsAbnormalHeat)
            {
                abText = Translator.Get("weather-tv.abnormalHeat");
            }

            if (Current.IsAbnormalChill)
            {
                abText = Translator.Get("weather-tv.abnormalChill");
            }

            string sysText = "";

            if (Current.trackerModel.WeatherSystemDays > 0)
            {
                if (Current.trackerModel.IsWeatherSystem)
                {
                    sysText = Translator.Get("weather-tv.systemMaint");
                }
            }

            //the first monster, describing the weather.
            string dWeather = "";

            if (!String.IsNullOrEmpty(SDVUtilities.GetFestivalName(SDate.Now())))
            {
                dWeather = Translator.Get("weather-tv.weat.festival", new { festivalName = SDVUtilities.GetFestivalName(SDate.Now()) });
            }

            if (Current.HasWeather(CurrentWeather.Wedding))
            {
                dWeather = Translator.Get("weather-tv.weat.wedding");
            }

            if (Current.HasWeather(CurrentWeather.Sunny))
            {
                dWeather = Translator.Get("weather-tv.weat.sunny");
            }

            if (Current.HasWeather(CurrentWeather.Rain) && !Current.HasWeather(CurrentWeather.Lightning))
            {
                dWeather = (Current.IsVariableRain ? Translator.Get("weather-tv.weat.rain.variable", new { rainDesc = GetRainDesc(Current.AmtOfRainDrops).Trim() })
                                                   : Translator.Get("weather-tv.weat.rain", new { rainDesc = GetRainDesc(Current.AmtOfRainDrops).Trim() }));
            }

            if (Current.HasWeather(CurrentWeather.Rain) && Current.HasWeather(CurrentWeather.Lightning) && !Current.HasWeather(CurrentWeather.ThunderFrenzy))
            {
                dWeather = Translator.Get("weather-tv.weat.thunderstorm");
            }

            if (Current.HasWeather(CurrentWeather.ThunderFrenzy))
            {
                dWeather = Translator.Get("weather-tv.weat.thunderfrenzy");
            }

            if (!Current.HasWeather(CurrentWeather.Rain) && Current.HasWeather(CurrentWeather.Lightning))
            {
                dWeather = Translator.Get("weather-tv.weat.drylightning");
            }

            if (Current.HasWeather(CurrentWeather.Blizzard) && !Current.HasWeather(CurrentWeather.WhiteOut))
            {
                dWeather = Translator.Get("weather-tv.weat.blizzard");
            }

            if (Current.HasWeather(CurrentWeather.WhiteOut))
            {
                dWeather = Translator.Get("weather-tv.weat.whiteout");
            }

            if (Current.HasWeather(CurrentWeather.Snow) && !Current.HasWeather(CurrentWeather.Blizzard) && !Current.HasWeather(CurrentWeather.WhiteOut) && !Current.HasWeather(CurrentWeather.Lightning))
            {
                dWeather = Translator.Get("weather-tv.weat.snowy");
            }

            if (Current.HasWeather(CurrentWeather.Snow) && !Current.HasWeather(CurrentWeather.Blizzard) && !Current.HasWeather(CurrentWeather.WhiteOut) && Current.HasWeather(CurrentWeather.Lightning))
            {
                dWeather = Translator.Get("weather-tv.weat.thundersnow");
            }

            if (Current.HasWeather(CurrentWeather.Sandstorm))
            {
                dWeather = Translator.Get("weather-tv.weat.sandstorms");
            }

            if (Current.HasWeather(CurrentWeather.Wind))
            {
                if (Game1.currentSeason == "winter")
                {
                    dWeather = Translator.Get("weather-tv.weat.windy.winter");
                }
                else
                {
                    dWeather = Translator.Get("weather-tv.weat.windy");
                }
            }

            string fog = "";

            if (Current.HasWeather(CurrentWeather.Fog))
            {
                if (!Current.HasWeather(CurrentWeather.Wedding))
                {
                    fog = Translator.Get("weather-tv.weat.fog", new { time = Current.GetFogTime() });
                }
                else
                {
                    fog = Translator.Get("weather-tv.weat.fogWed", new { time = Current.GetFogTime() });
                }
            }

            //ending up the current conditions.
            string tHazard = "";

            if (Current.HasWeather(CurrentWeather.Heatwave))
            {
                tHazard = Translator.Get("weather-tv.tempHazard.heat");
            }

            if (Current.HasWeather(CurrentWeather.Frost))
            {
                tHazard = Translator.Get("weather-tv.tempHazard.cold",
                                         new { time = (Game1.currentSeason == "spring"
                          ? Translator.Get("weather-tv.tempHazard.cold.spring") :
                                                       Translator.Get("weather-tv.tempHazard.cold.fall")) });
            }

            string rRate = "";

            if (Current.HasWeather(CurrentWeather.Rain))
            {
                rRate = Translator.Get("weather-tv.rainfallRate", new { rate = WeatherUtilities.GetRainfallAmt(Current.AmtOfRainDrops).ToString("N2") });
            }

            var transParams = new Dictionary <string, string> {
                { "time", time },
                { "currentTemp", GetTemperatureString(Current.GetCurrentTemperature(Game1.timeOfDay)) },
                { "abnormalText", abText },
                { "systemText", sysText },
                { "descWeather", dWeather },
                { "fogText", fog },
                { "tempHazard", tHazard },
                { "rainfallRate", rRate }
            };

            ret += Translator.Get("weather-tv.currentCond", transParams);
            transParams.Clear();

            //now, tomorrow!! :D

            sysText = "";
            if (Current.trackerModel.WeatherSystemDays > 0)
            {
                if (Current.trackerModel.IsWeatherSystem)
                {
                    sysText = Translator.Get("weather-tv.tmrw.systemMaint",
                                             new { desc = Translator.Get("weather-location.system.desc." + Dice.Next(6)) });
                }
                if (!Current.trackerModel.IsWeatherSystem && (Game1.weatherForTomorrow != WeatherUtilities.GetWeatherCode()))
                {
                    sysText = Translator.Get("weather-tv.tmrw.systemEnding",
                                             new { desc = Translator.Get("weather-location.system.desc." + Dice.Next(6)), direction = Translator.Get("weather-location.system.move." + Dice.Next(4)) });
                }
            }
            else
            {
                sysText = Translator.Get("weather-tv.tmrw.systemNone");
            }

            //now weather
            switch (Game1.weatherForTomorrow)
            {
            case Game1.weather_rain:
                dWeather = Translator.Get("weather-tv.rain." + Dice.Next(2));
                break;

            case Game1.weather_festival:
                dWeather = Translator.Get("weather-tv.festival", new { festName = SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) });
                break;

            case Game1.weather_debris:
                dWeather = Translator.Get("weather-tv.debris." + Dice.Next(2));
                break;

            case Game1.weather_snow:
                dWeather = Translator.Get("weather-tv.snowy." + Dice.Next(2));
                break;

            case Game1.weather_wedding:
                dWeather = Translator.Get("weather-tv.wedding");
                break;

            case Game1.weather_lightning:
                dWeather = Translator.Get("weather-tv.tstorm." + Dice.Next(2));
                break;

            case Game1.weather_sunny:
            default:
                dWeather = Translator.Get("weather-tv.sunny." + Dice.Next(2));
                break;
            }

            //overrides for festival and wedding (just in case, my paranoia is spiking. :|)
            if (!String.IsNullOrEmpty(SDVUtilities.GetFestivalName(SDate.Now().AddDays(1))))
            {
                dWeather = Translator.Get("weather-tv.festival", new { festName = SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) });
            }
            if (Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1)
            {
                dWeather = Translator.Get("weather-tv.wedding");
            }

            fog = "";
            //now, the fog string
            if (fogOdds >= .6)
            {
                fog = Translator.Get("weather-tv.fogChance");
            }

            //tHazard string

            if (Current.TomorrowHigh > (Current.TodayHigh + 1.5))
            {
                tHazard = Translator.Get("weather-tv.tmrw.warmer", new
                {
                    high = GetTemperatureString(Current.TomorrowHigh),
                    low  = GetTemperatureString(Current.TomorrowLow),
                });
            }
            else if ((Current.TomorrowHigh < (Current.TodayHigh - 1.5)))
            {
                tHazard = Translator.Get("weather-tv.tmrw.cooler", new
                {
                    high = GetTemperatureString(Current.TomorrowHigh),
                    low  = GetTemperatureString(Current.TomorrowLow),
                });
            }
            else
            {
                tHazard = Translator.Get("weather-tv.tmrw.effsame", new
                {
                    high = GetTemperatureString(Current.TomorrowHigh),
                    low  = GetTemperatureString(Current.TomorrowLow),
                });
            }


            transParams.Add("sysText", sysText);
            transParams.Add("weather", dWeather);
            transParams.Add("fogChance", fog);
            transParams.Add("tempString", tHazard);

            ret += Translator.Get("weather-tv.tomorrowForecast", transParams);
            return(ret);
        }
Пример #2
0
        internal string GenerateTVForecast(WeatherConditions Current, string MoonPhase = "")
        {
            //assemble params
            var talkParams = new Dictionary <string, string>
            {
                { "location", GetRandomLocation() },
                { "descWeather", GetWeather(Current, Game1.dayOfMonth, Game1.currentSeason) },
                { "festival", SDVUtilities.GetFestivalName(SDate.Now()) },
                { "festivalTomorrow", SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) },
                { "fogTime", Current.GetFogTime().ToString() },
                { "todayHigh", GetTemperatureString(Current.TodayHigh) },
                { "todayLow", GetTemperatureString(Current.TodayLow) },
                { "tomorrowWeather", GetWeather(Game1.weatherForTomorrow, Game1.dayOfMonth, Game1.currentSeason, true) },
                { "tomorrowHigh", GetTemperatureString(Current.TomorrowHigh) },
                { "tomorrowLow", GetTemperatureString(Current.TomorrowLow) },
                { "condWarning", GetCondWarning(Current) },
                { "condString", GetCondWarning(Current) },
                { "eveningFog", GetEveningFog(Current) }
            };

            //select the weather string for the TV.
            SDVTimePeriods CurrentPeriod = SDVTime.CurrentTimePeriod; //get the current time period
            int            nRandom       = OurDice.Next(2);

            //blood moon checks
            if ((Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1) && MoonPhase == "Blood Moon")
            {
                talkParams["tomrrowWeather"] = Helper.Get($"weat-{Game1.currentSeason}.sunny.{nRandom}");
                return(Helper.Get("weat-wedTomorrow.BM.0", talkParams));
            }

            //festival tomorrow
            else if (SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) != "" && MoonPhase == "Blood Moon")
            {
                return(Helper.Get("weat-fesTomorrow.BM.0", talkParams));
            }

            else if (MoonPhase == "Blood Moon")
            {
                return(Helper.Get("weat-gen.bloodmoon.0", talkParams));
            }

            //first, check for special conditions -fog, festival, wedding
            else if (Current.HasWeather(CurrentWeather.Fog))
            {
                return(Helper.Get($"weat-loc.fog.{nRandom}", talkParams));
            }

            //festival today
            else if (Current.HasWeather(CurrentWeather.Festival))
            {
                return(Helper.Get("weat-fesToday.0", talkParams));
            }

            //festival tomorrow
            else if (SDVUtilities.GetFestivalName(SDate.Now().AddDays(1)) != "")
            {
                return(Helper.Get("weat-fesTomorrow.0", talkParams));
            }

            //wedding today
            else if (Current.HasWeather(CurrentWeather.Wedding))
            {
                return(Helper.Get("weat-wedToday.0", talkParams));
            }

            //wedding tomrrow
            else if (Game1.player.spouse != null && Game1.player.isEngaged() && Game1.player.friendshipData[Game1.player.spouse].CountdownToWedding == 1)
            {
                talkParams["tomrrowWeather"] = Helper.Get($"weat-{Game1.currentSeason}.sunny.{nRandom}");
                return(Helper.Get("weat-wedTomorrow.0", talkParams));
            }

            if (OurDice.NextDoublePositive() > .45)
            {
                if (CurrentPeriod == SDVTimePeriods.Morning)
                {
                    return(Helper.Get($"weat-morn.{nRandom}", talkParams));
                }
                else if (CurrentPeriod == SDVTimePeriods.Afternoon)
                {
                    return(Helper.Get($"weat-afternoon.{nRandom}", talkParams));
                }
                else if (CurrentPeriod == SDVTimePeriods.Evening)
                {
                    return(Helper.Get($"weat-evening.{nRandom}", talkParams));
                }
                else if (CurrentPeriod == SDVTimePeriods.Night)
                {
                    return(Helper.Get($"weat-night.{nRandom}", talkParams));
                }
                else if (CurrentPeriod == SDVTimePeriods.Midnight)
                {
                    return(Helper.Get($"weat-midnight.{nRandom}", talkParams));
                }
                else if (CurrentPeriod == SDVTimePeriods.LateNight)
                {
                    return(Helper.Get($"weat-latenight.{nRandom}", talkParams));
                }
            }
            else
            {
                //ye olde generic!
                return(Helper.Get($"weat-loc.{nRandom}", talkParams));
            }

            return("");
        }