Esempio n. 1
0
 private string GetEveningFog(WeatherConditions Current)
 {
     if (Current.GenerateEveningFog)
     {
         var fList = Current.GetWeatherMatchingType("Fog");
         foreach (ISDVWeather weat in fList)
         {
             if (weat is FerngillFog fWeat)
             {
                 if (Current.GetWeatherMatchingType("Fog").First().IsWeatherVisible&& (SDVTime.CurrentTime > new SDVTime(1200)))
                 {
                     return(Helper.Get("weather-condition.fog", new { fogTime = fWeat.WeatherExpirationTime.ToString() }));
                 }
                 else
                 {
                     if (fWeat.WeatherBeginTime != fWeat.WeatherExpirationTime)
                     {
                         return(Helper.Get("weather-condition.evenFog", new { startTime = fWeat.WeatherBeginTime.ToString(), endTime = fWeat.WeatherExpirationTime.ToString() }));
                     }
                     else
                     {
                         return("");
                     }
                 }
             }
         }
         return("");
     }
     else
     {
         return("");
     }
 }
Esempio n. 2
0
        internal string GenerateMenuPopup(WeatherConditions Current, string MoonPhase = "", string NightTime = "")
        {
            string text;

            if (SDate.Now().Season == "spring" && SDate.Now().Day == 1)
            {
                text = Translator.Get("weather-menu.openingS1D1", new { descDay = Translator.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine;
            }
            else if (SDate.Now().Season == "winter" && SDate.Now().Day == 28)
            {
                text = Translator.Get("weather-menu.openingS4D28", new { descDay = Translator.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine;
            }
            else
            {
                text = Translator.Get("weather-menu.opening", new { descDay = Translator.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.Sandstorm))
            {
                text += Translator.Get("weather-menu.condition.sandstorm") + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.Heatwave))
            {
                text += Translator.Get("weather-menu.condition.heatwave") + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.Frost))
            {
                text += Translator.Get("weather-menu.condition.frost") + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.WhiteOut))
            {
                text += Translator.Get("weather-menu.condition.whiteOut") + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.ThunderFrenzy))
            {
                text += Translator.Get("weather-menu.condition.thunderFrenzy") + Environment.NewLine;
            }

            if (Current.IsVariableRain)
            {
                switch (WeatherUtilities.GetRainCategory(Current.AmtOfRainDrops))
                {
                case RainLevels.Severe:
                    text += Translator.Get("weather-condition.vrain.severe_sw") + Environment.NewLine;
                    break;

                case RainLevels.Torrential:
                    text += Translator.Get("weather-condition.vrain.torrential_sw") + Environment.NewLine;
                    break;

                case RainLevels.Typhoon:
                    text += Translator.Get("weather-condition.vrain.typhoon_sw") + Environment.NewLine;
                    break;

                case RainLevels.NoahsFlood:
                    text += Translator.Get("weather-condition.vrain.godswrath_sw") + Environment.NewLine;
                    break;

                default:
                    break;
                }
            }

            if (MoonPhase == "Blood Moon")
            {
                text += Translator.Get("weather-menu.condition.bloodmoon") + Environment.NewLine;
            }

            if (ClimatesOfFerngill.UseLunarDisturbancesApi && ClimatesOfFerngill.MoonAPI.IsSolarEclipse())
            {
                text += Translator.Get("weather-menu.condition.solareclipse") + Environment.NewLine;
            }

            ISDVWeather CurrentFog = Current.GetWeatherMatchingType("Fog").First();
            string      fogString  = "";

            //  If the fog is visible, we don't need to display fog information. However, if it's in the morning,
            //    and we know evening fog is likely, we should display the message it's expected
            // That said, if it's not, we need to pull the fog information down, assuming it's been reset. This checks that the fog end
            //    time is *before* now. To avoid nested trinary statements..
            if (SDVTime.CurrentTime < CurrentFog.WeatherExpirationTime && Current.GenerateEveningFog && CurrentFog.WeatherBeginTime < new SDVTime(1200))
            {
                fogString = Translator.Get("weather-menu.expectedFog");
            }
            if (CurrentFog.WeatherBeginTime > SDVTime.CurrentTime && Current.GenerateEveningFog)
            {
                fogString = Translator.Get("weather-menu.fogFuture",
                                           new
                {
                    fogTime = CurrentFog.WeatherBeginTime.ToString(),
                    endFog  = CurrentFog.WeatherExpirationTime.ToString()
                });
            }

            //Current Conditions.
            string currentMenu;

            if (Current.HasWeather(CurrentWeather.Rain) && Current.IsVariableRain)
            {
                currentMenu = "weather-menu.currentRainfall";
            }
            else
            {
                currentMenu = "weather-menu.current";
            }

            text += Translator.Get(currentMenu, new
            {
                todayCondition = Current.HasWeather(CurrentWeather.Fog)
                                        ? Translator.Get("weather-menu.fog", new { condition = GetBasicWeather(Current), fogTime = CurrentFog.IsWeatherVisible
                                                ? CurrentFog.WeatherExpirationTime.ToString()
                                                : "" })
                                        : GetBasicWeather(Current),
                tempString      = GetTemperatureString(Current.GetCurrentTemperature(Game1.timeOfDay)),
                todayHigh       = GetTemperatureString(Current.TodayHigh),
                todayLow        = GetTemperatureString(Current.TodayLow),
                currentRainfall = WeatherUtilities.GetRainfallAmt(Current.AmtOfRainDrops).ToString("N2"),
                fogString
            }) + Environment.NewLine;

            //Tomorrow weather
            text += Translator.Get("weather-menu.tomorrow",
                                   new {
                tomorrowCondition = GetBasicWeather(Game1.weatherForTomorrow),
                tomorrowLow       = GetTemperatureString(Current.TomorrowLow),
                tomorrowHigh      = GetTemperatureString(Current.TomorrowHigh)
            }) + Environment.NewLine;

            //now, night time
            if (!String.IsNullOrEmpty(NightTime))
            {
                text += NightTime + Environment.NewLine;
            }

            if (ClimatesOfFerngill.UseLunarDisturbancesApi)
            {
                if (ClimatesOfFerngill.MoonAPI.IsMoonUp(Game1.timeOfDay))
                {
                    text += Translator.Get("weather-menu.desc-moonNotUp", new { moonPhase = ClimatesOfFerngill.MoonAPI.GetCurrentMoonPhase(), moonRise = ClimatesOfFerngill.MoonAPI.GetMoonRise(), moonSet = ClimatesOfFerngill.MoonAPI.GetMoonSet() });
                }
                else
                {
                    text += Translator.Get("weather-menu.desc-moonUp", new { moonPhase = ClimatesOfFerngill.MoonAPI.GetCurrentMoonPhase(), moonSet = ClimatesOfFerngill.MoonAPI.GetMoonSet() });
                }
            }

            //new line replacer
            text.Replace("[NLK]", Environment.NewLine);

            return(text);
        }
Esempio n. 3
0
        internal string GenerateMenuPopup(WeatherConditions Current, string MoonPhase = "", string NightTime = "")
        {
            string text = "";

            if (SDate.Now().Season == "spring" && SDate.Now().Day == 1)
            {
                text = Helper.Get("weather-menu.openingS1D1", new { descDay = Helper.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine;
            }
            else if (SDate.Now().Season == "winter" && SDate.Now().Day == 28)
            {
                text = Helper.Get("weather-menu.openingS4D28", new { descDay = Helper.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine;
            }
            else
            {
                text = Helper.Get("weather-menu.opening", new { descDay = Helper.Get($"date{UpperSeason(SDate.Now().Season)}{SDate.Now().Day}") }) + Environment.NewLine + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.Heatwave))
            {
                text += Helper.Get("weather-menu.condition.heatwave") + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.Frost))
            {
                text += Helper.Get("weather-menu.condition.frost") + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.WhiteOut))
            {
                text += Helper.Get("weather-menu.condition.whiteOut") + Environment.NewLine;
            }

            if (Current.ContainsCondition(CurrentWeather.ThunderFrenzy))
            {
                text += Helper.Get("weather-menu.condition.thunderFrenzy") + Environment.NewLine;
            }

            if (MoonPhase == "Blood Moon")
            {
                text += Helper.Get("weather-menu.condition.bloodmoon") + Environment.NewLine;
            }

            ISDVWeather CurrentFog = Current.GetWeatherMatchingType("Fog").First();
            string      fogString  = "";

            //  If the fog is visible, we don't need to display fog information. However, if it's in the morning,
            //    and we know evening fog is likely, we should display the message it's expected
            // That said, if it's not, we need to pull the fog information down, assuming it's been reset. This checks that the fog end
            //    time is *before* now. To avoid nested trinary statements..
            if (SDVTime.CurrentTime < CurrentFog.WeatherExpirationTime && Current.GenerateEveningFog && CurrentFog.WeatherBeginTime < new SDVTime(1200))
            {
                fogString = Helper.Get("weather-menu.expectedFog");
            }
            if (CurrentFog.WeatherBeginTime > SDVTime.CurrentTime && Current.GenerateEveningFog)
            {
                fogString = Helper.Get("weather-menu.fogFuture",
                                       new
                {
                    fogTime = CurrentFog.WeatherBeginTime.ToString(),
                    endFog  = CurrentFog.WeatherExpirationTime.ToString()
                });
            }

            //Current Conditions.
            text += Helper.Get("weather-menu.current", new
            {
                todayCondition = Current.HasWeather(CurrentWeather.Fog) ? Helper.Get("weather-menu.fog", new { condition = GetBasicWeather(Current, Game1.currentSeason), fogTime = CurrentFog.IsWeatherVisible ? CurrentFog.WeatherExpirationTime.ToString() : "" }) : GetBasicWeather(Current, Game1.currentSeason),

                todayHigh = GetTemperatureString(Current.TodayHigh),
                todayLow  = GetTemperatureString(Current.TodayLow),
                fogString
            }) + Environment.NewLine;

            //Tomorrow weather
            text += Helper.Get("weather-menu.tomorrow",
                               new {
                tomorrowCondition = GetBasicWeather(Game1.weatherForTomorrow, Game1.currentSeason),
                tomorrowLow       = GetTemperatureString(Current.TomorrowLow),
                tomorrowHigh      = GetTemperatureString(Current.TomorrowHigh)
            }) + Environment.NewLine;

            //now, night time
            if (NightTime != "")
            {
                text += Environment.NewLine;
                text += NightTime + Environment.NewLine;
            }

            return(text);
        }
Esempio n. 4
0
        /* **************************************************************
         * console commands
         * **************************************************************
         */

        /// <summary>
        /// This function changes the weather (Console Command)
        /// </summary>
        /// <param name="arg1">The command used</param>
        /// <param name="arg2">The console command parameters</param>
        private void WeatherChangeFromConsole(string arg1, string[] arg2)
        {
            if (!Context.IsMainPlayer)
            {
                return;
            }

            if (arg2.Length < 1)
            {
                return;
            }

            string ChosenWeather = arg2[0];

            switch (ChosenWeather)
            {
            case "rain":
                Game1.isSnowing = Game1.isLightning = Game1.isDebrisWeather = false;
                Game1.isRaining = true;
                Game1.debrisWeather.Clear();
                Conditions.GetWeatherMatchingType("Blizzard").First().EndWeather();
                Conditions.GetWeatherMatchingType("WhiteOut").First().EndWeather();
                Monitor.Log(Helper.Translation.Get("console-text.weatherset_rain"), LogLevel.Info);
                break;

            case "storm":
                Game1.isSnowing   = Game1.isDebrisWeather = false;
                Game1.isLightning = Game1.isRaining = true;
                Game1.debrisWeather.Clear();
                Conditions.GetWeatherMatchingType("Blizzard").First().EndWeather();
                Conditions.GetWeatherMatchingType("WhiteOut").First().EndWeather();
                Monitor.Log(Helper.Translation.Get("console-text.weatherset_storm"), LogLevel.Info);
                break;

            case "snow":
                Game1.isRaining = Game1.isLightning = Game1.isDebrisWeather = false;
                Game1.isSnowing = true;
                Game1.debrisWeather.Clear();
                Conditions.GetWeatherMatchingType("Blizzard").First().EndWeather();
                Conditions.GetWeatherMatchingType("WhiteOut").First().EndWeather();
                Monitor.Log(Helper.Translation.Get("console-text.weatherset_snow"), LogLevel.Info);
                break;

            case "debris":
                Game1.isSnowing = Game1.isLightning = Game1.isRaining = false;
                Conditions.GetWeatherMatchingType("Blizzard").First().EndWeather();
                Conditions.GetWeatherMatchingType("Fog").First().EndWeather();
                Conditions.GetWeatherMatchingType("WhiteOut").First().EndWeather();
                Game1.isDebrisWeather = true;
                Game1.populateDebrisWeatherArray();
                Monitor.Log(Helper.Translation.Get("console-text.weatherset_debris", LogLevel.Info));
                break;

            case "sunny":
                Conditions.GetWeatherMatchingType("Blizzard").First().EndWeather();
                Conditions.GetWeatherMatchingType("Fog").First().EndWeather();
                Conditions.GetWeatherMatchingType("WhiteOut").First().EndWeather();
                Game1.debrisWeather.Clear();
                Game1.isSnowing = Game1.isLightning = Game1.isRaining = Game1.isDebrisWeather = false;
                Monitor.Log(Helper.Translation.Get("console-text.weatherset_sun", LogLevel.Info));
                break;

            case "blizzard":
                Game1.isRaining = Game1.isLightning = Game1.isDebrisWeather = false;
                Game1.isSnowing = true;
                Game1.debrisWeather.Clear();
                Conditions.GetWeatherMatchingType("Blizzard").First().CreateWeather();
                Conditions.GetWeatherMatchingType("WhiteOut").First().EndWeather();
                Monitor.Log(Helper.Translation.Get("console-text.weatherset_snow"), LogLevel.Info);
                break;

            case "whiteout":
                Game1.isRaining = Game1.isLightning = Game1.isDebrisWeather = false;
                Game1.isSnowing = true;
                Game1.debrisWeather.Clear();
                Conditions.GetWeatherMatchingType("Blizzard").First().CreateWeather();
                Conditions.GetWeatherMatchingType("WhiteOut").First().CreateWeather();
                Monitor.Log(Helper.Translation.Get("console-text.weatherset_snow"), LogLevel.Info);
                break;
            }

            Game1.updateWeatherIcon();
            Conditions.SetTodayWeather();
        }