private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, string questRewardImageUrl) { var questMessage = this.GetQuestMessage(); var questConditions = this.GetConditions(); var questReward = this.GetReward(); var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var templatePath = Path.Combine(whConfig.StaticMaps.TemplatesFolder, whConfig.StaticMaps.Quests.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, whConfig.Urls.StaticMap, whConfig.StaticMaps.Quests.ZoomLevel, Latitude, Longitude, questRewardImageUrl, null); var gmapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? gmapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? appleMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? wazeMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? scannerMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); Geofence.Location address = null; if (!string.IsNullOrEmpty(whConfig.GoogleMapsKey)) { address = Utils.GetGoogleAddress(city, Latitude, Longitude, whConfig.GoogleMapsKey); } else if (!string.IsNullOrEmpty(whConfig.NominatimEndpoint)) { address = Utils.GetNominatimAddress(city, Latitude, Longitude, whConfig.NominatimEndpoint); } //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "quest_task", questMessage }, { "quest_conditions", questConditions }, { "quest_reward", questReward }, { "quest_reward_img_url", questRewardImageUrl }, { "has_quest_conditions", Convert.ToString(!string.IsNullOrEmpty(questConditions)) }, { "is_ditto", Convert.ToString(IsDitto) }, { "is_shiny", Convert.ToString(IsShiny) }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Math.Round(Latitude, 5).ToString() }, { "lng_5", Math.Round(Longitude, 5).ToString() }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, //Pokestop properties { "pokestop_id", PokestopId ?? defaultMissingValue }, { "pokestop_name", PokestopName ?? defaultMissingValue }, { "pokestop_url", PokestopUrl ?? defaultMissingValue }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
private async Task <IReadOnlyDictionary <string, string> > GetProperties(DiscordGuild guild, WhConfig whConfig, string city, string pokemonImageUrl) { var pkmnInfo = MasterFile.GetPokemon(Id, FormId); var pkmnName = Translator.Instance.GetPokemonName(Id); var form = Translator.Instance.GetFormName(FormId); var costume = Translator.Instance.GetCostumeName(Costume); var gender = Gender.GetPokemonGenderIcon(); var genderEmoji = Gender.GetGenderEmojiIcon(); var level = Level; var size = Size?.ToString(); var weather = Weather?.ToString(); var hasWeather = Weather.HasValue && Weather != WeatherType.None; var isWeatherBoosted = pkmnInfo?.IsWeatherBoosted(Weather ?? WeatherType.None); var weatherKey = $"weather_{Convert.ToInt32(Weather ?? WeatherType.None)}"; var weatherEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[weatherKey]) ? MasterFile.Instance.CustomEmojis.ContainsKey(weatherKey) && Weather != WeatherType.None ? (Weather ?? WeatherType.None).GetWeatherEmojiIcon() : string.Empty : MasterFile.Instance.CustomEmojis[weatherKey]; var move1 = "Unknown"; var move2 = "Unknown"; if (int.TryParse(FastMove, out var fastMoveId)) { move1 = Translator.Instance.GetMoveName(fastMoveId); } if (int.TryParse(ChargeMove, out var chargeMoveId)) { move2 = Translator.Instance.GetMoveName(chargeMoveId); } var type1 = pkmnInfo?.Types?[0]; var type2 = pkmnInfo?.Types?.Count > 1 ? pkmnInfo.Types?[1] : PokemonType.None; var type1Emoji = pkmnInfo?.Types?[0].GetTypeEmojiIcons(); var type2Emoji = pkmnInfo?.Types?.Count > 1 ? pkmnInfo?.Types?[1].GetTypeEmojiIcons() : string.Empty; var typeEmojis = $"{type1Emoji} {type2Emoji}"; var catchPokemon = IsDitto ? Translator.Instance.GetPokemonName(DisplayPokemonId ?? Id) : pkmnName; var isShiny = Shiny ?? false; var height = double.TryParse(Height, out var realHeight) ? Math.Round(realHeight).ToString() : ""; var weight = double.TryParse(Weight, out var realWeight) ? Math.Round(realWeight).ToString() : ""; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var templatePath = Path.Combine(whConfig.StaticMaps.TemplatesFolder, whConfig.StaticMaps.Pokemon.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, whConfig.Urls.StaticMap, whConfig.StaticMaps.Pokemon.ZoomLevel, Latitude, Longitude, pokemonImageUrl, null); var gmapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? gmapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? appleMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? wazeMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? scannerMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); Geofence.Location address = null; if (!string.IsNullOrEmpty(whConfig.GoogleMapsKey)) { address = Utils.GetGoogleAddress(city, Latitude, Longitude, whConfig.GoogleMapsKey); } else if (!string.IsNullOrEmpty(whConfig.NominatimEndpoint)) { address = Utils.GetNominatimAddress(city, Latitude, Longitude, whConfig.NominatimEndpoint); } //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var pokestop = Pokestop.Pokestops.ContainsKey(PokestopId) ? Pokestop.Pokestops[PokestopId] : null; var isGreat = MatchesGreatLeague; var isUltra = MatchesUltraLeague; var greatLeagueEmoji = PvPLeague.Great.GetLeagueEmojiIcon(); var ultraLeagueEmoji = PvPLeague.Ultra.GetLeagueEmojiIcon(); var isPvP = isGreat || isUltra; var pvpStats = await GetPvP(); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { // Main properties { "pkmn_id", Convert.ToString(Id) }, { "pkmn_id_3", Id.ToString("D3") }, { "pkmn_name", pkmnName }, { "pkmn_img_url", pokemonImageUrl }, { "form", form }, { "form_id", Convert.ToString(FormId) }, { "form_id_3", FormId.ToString("D3") }, { "costume", costume ?? defaultMissingValue }, { "costume_id", Convert.ToString(Costume) }, { "costume_id_3", Costume.ToString("D3") }, { "cp", CP ?? defaultMissingValue }, { "lvl", level ?? defaultMissingValue }, { "gender", gender }, { "gender_emoji", genderEmoji }, { "size", size ?? defaultMissingValue }, { "move_1", move1 ?? defaultMissingValue }, { "move_2", move2 ?? defaultMissingValue }, { "moveset", $"{move1}/{move2}" }, { "type_1", type1?.ToString() ?? defaultMissingValue }, { "type_2", type2?.ToString() ?? defaultMissingValue }, { "type_1_emoji", type1Emoji }, { "type_2_emoji", type2Emoji }, { "types", $"{type1} | {type2}" }, { "types_emoji", typeEmojis }, { "atk_iv", Attack ?? defaultMissingValue }, { "def_iv", Defense ?? defaultMissingValue }, { "sta_iv", Stamina ?? defaultMissingValue }, { "iv", IV ?? defaultMissingValue }, { "iv_rnd", IVRounded ?? defaultMissingValue }, { "is_shiny", Convert.ToString(isShiny) }, // Catch rate properties { "has_capture_rates", Convert.ToString(CatchRate1.HasValue && CatchRate2.HasValue && CatchRate3.HasValue) }, { "capture_1", CatchRate1.HasValue ? Math.Round(CatchRate1.Value * 100).ToString() : string.Empty }, { "capture_2", CatchRate2.HasValue ? Math.Round(CatchRate2.Value * 100).ToString() : string.Empty }, { "capture_3", CatchRate3.HasValue ? Math.Round(CatchRate3.Value * 100).ToString() : string.Empty }, { "capture_1_emoji", CaptureRateType.PokeBall.GetCaptureRateEmojiIcon() }, { "capture_2_emoji", CaptureRateType.GreatBall.GetCaptureRateEmojiIcon() }, { "capture_3_emoji", CaptureRateType.UltraBall.GetCaptureRateEmojiIcon() }, // PvP stat properties { "is_great", Convert.ToString(isGreat) }, { "is_ultra", Convert.ToString(isUltra) }, { "is_pvp", Convert.ToString(isPvP) }, //{ "great_league_stats", greatLeagueStats }, //{ "ultra_league_stats", ultraLeagueStats }, { "great_league_emoji", greatLeagueEmoji }, { "ultra_league_emoji", ultraLeagueEmoji }, { "pvp_stats", pvpStats }, // Other properties { "height", height ?? defaultMissingValue }, { "weight", weight ?? defaultMissingValue }, { "is_ditto", Convert.ToString(IsDitto) }, { "original_pkmn_id", Convert.ToString(DisplayPokemonId) }, { "original_pkmn_id_3", (DisplayPokemonId ?? 0).ToString("D3") }, { "original_pkmn_name", catchPokemon }, { "is_weather_boosted", Convert.ToString(isWeatherBoosted) }, { "has_weather", Convert.ToString(hasWeather) }, { "weather", weather ?? defaultMissingValue }, { "weather_emoji", weatherEmoji ?? defaultMissingValue }, { "username", Username ?? defaultMissingValue }, { "spawnpoint_id", SpawnpointId ?? defaultMissingValue }, { "encounter_id", EncounterId ?? defaultMissingValue }, // Time properties { "despawn_time", DespawnTime.ToString("hh:mm:ss tt") }, { "despawn_time_24h", DespawnTime.ToString("HH:mm:ss") }, { "despawn_time_verified", DisappearTimeVerified ? "" : "~" }, { "is_despawn_time_verified", Convert.ToString(DisappearTimeVerified) }, { "time_left", SecondsLeft.ToReadableString(true) ?? defaultMissingValue }, // Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Convert.ToString(Latitude) }, { "lng", Convert.ToString(Longitude) }, { "lat_5", Convert.ToString(Math.Round(Latitude, 5)) }, { "lng_5", Convert.ToString(Math.Round(Longitude, 5)) }, // Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, // Pokestop properties { "near_pokestop", Convert.ToString(pokestop != null) }, { "pokestop_id", PokestopId ?? defaultMissingValue }, { "pokestop_name", pokestop?.Name ?? defaultMissingValue }, { "pokestop_url", pokestop?.Url ?? defaultMissingValue }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, // Event properties { "is_event", Convert.ToString(IsEvent.HasValue && IsEvent.Value) }, { "date_time", DateTime.Now.ToString() }, // Misc properties { "br", "\r\n" } }; return(await Task.FromResult(dict)); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city) { var lureImageUrl = IconFetcher.Instance.GetLureIcon(whConfig.Servers[guild.Id].IconStyle, LureType); var invasionImageUrl = IconFetcher.Instance.GetInvasionIcon(whConfig.Servers[guild.Id].IconStyle, GruntType); var imageUrl = HasInvasion ? invasionImageUrl : HasLure ? lureImageUrl : Url; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var templatePath = Path.Combine(whConfig.StaticMaps.TemplatesFolder, HasInvasion ? whConfig.StaticMaps.Invasions.TemplateFile : HasLure ? whConfig.StaticMaps.Lures.TemplateFile : whConfig.StaticMaps.Lures.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, whConfig.Urls.StaticMap, HasInvasion ? whConfig.StaticMaps.Invasions.ZoomLevel : HasLure ? whConfig.StaticMaps.Lures.ZoomLevel : whConfig.StaticMaps.Lures.ZoomLevel, Latitude, Longitude, imageUrl, null); var gmapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? gmapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? appleMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? wazeMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? scannerMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); Geofence.Location address = null; if (!string.IsNullOrEmpty(whConfig.GoogleMapsKey)) { address = Utils.GetGoogleAddress(city, Latitude, Longitude, whConfig.GoogleMapsKey); } else if (!string.IsNullOrEmpty(whConfig.NominatimEndpoint)) { address = Utils.GetNominatimAddress(city, Latitude, Longitude, whConfig.NominatimEndpoint); } //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var invasion = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? MasterFile.Instance.GruntTypes[GruntType] : null; var leaderString = Translator.Instance.Translate("grunt_" + Convert.ToInt32(GruntType)); var pokemonType = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? Commands.Notifications.GetPokemonTypeFromString(invasion?.Type) : PokemonType.None; var invasionTypeEmoji = pokemonType == PokemonType.None ? leaderString : pokemonType.GetTypeEmojiIcons(); var invasionEncounters = GruntType > 0 ? invasion.GetPossibleInvasionEncounters() : string.Empty; const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "has_lure", Convert.ToString(HasLure) }, { "lure_type", LureType.ToString() }, { "lure_expire_time", LureExpireTime.ToLongTimeString() }, { "lure_expire_time_24h", LureExpireTime.ToString("HH:mm:ss") }, { "lure_expire_time_left", LureExpireTime.GetTimeRemaining().ToReadableStringNoSeconds() }, { "has_invasion", Convert.ToString(HasInvasion) }, { "grunt_type", invasion?.Type }, { "grunt_type_emoji", invasionTypeEmoji }, { "grunt_gender", invasion?.Grunt }, { "invasion_expire_time", InvasionExpireTime.ToLongTimeString() }, { "invasion_expire_time_24h", InvasionExpireTime.ToString("HH:mm:ss") }, { "invasion_expire_time_left", InvasionExpireTime.GetTimeRemaining().ToReadableStringNoSeconds() }, { "invasion_encounters", $"**Encounter Reward Chance:**\r\n" + invasionEncounters }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Math.Round(Latitude, 5).ToString() }, { "lng_5", Math.Round(Longitude, 5).ToString() }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, //Pokestop properties { "pokestop_id", PokestopId ?? defaultMissingValue }, { "pokestop_name", Name ?? defaultMissingValue }, { "pokestop_url", Url ?? defaultMissingValue }, { "lure_img_url", lureImageUrl }, { "invasion_img_url", invasionImageUrl }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, string weatherImageUrl) { var weather = Translator.Instance.GetWeather(GameplayCondition); var weatherKey = $"weather_{Convert.ToInt32(GameplayCondition)}"; var weatherEmoji = MasterFile.Instance.Emojis.ContainsKey(weatherKey) && GameplayCondition != WeatherType.None ? GameplayCondition.GetWeatherEmojiIcon() : string.Empty; var hasWeather = GameplayCondition != WeatherType.None; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var templatePath = Path.Combine(whConfig.StaticMaps.TemplatesFolder, whConfig.StaticMaps.Weather.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, whConfig.Urls.StaticMap, whConfig.StaticMaps.Weather.ZoomLevel, Latitude, Longitude, weatherImageUrl, null); var gmapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? gmapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? appleMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? wazeMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? scannerMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); Geofence.Location address = null; if (!string.IsNullOrEmpty(whConfig.GoogleMapsKey)) { address = Utils.GetGoogleAddress(city, Latitude, Longitude, whConfig.GoogleMapsKey); } else if (!string.IsNullOrEmpty(whConfig.NominatimEndpoint)) { address = Utils.GetNominatimAddress(city, Latitude, Longitude, whConfig.NominatimEndpoint); } //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "id", Id.ToString() }, { "weather_condition", weather }, { "has_weather", Convert.ToString(hasWeather) }, { "weather", weather ?? defaultMissingValue }, { "weather_emoji", weatherEmoji ?? defaultMissingValue }, { "weather_img_url", weatherImageUrl }, { "wind_direction", WindDirection.ToString() }, { "wind_level", WindLevel.ToString() }, { "raid_level", RainLevel.ToString() }, { "cloud_level", CloudLevel.ToString() }, { "fog_level", FogLevel.ToString() }, { "snow_level", SnowLevel.ToString() }, { "warn_weather", Convert.ToString(WarnWeather ?? false) }, { "special_effect_level", SpecialEffectLevel.ToString() }, { "severity", Severity.ToString() }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Math.Round(Latitude, 5).ToString() }, { "lng_5", Math.Round(Longitude, 5).ToString() }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, string raidImageUrl) { var pkmnInfo = MasterFile.GetPokemon(PokemonId, Form); var name = IsEgg ? "Egg" /*TODO: Localize*/ : Translator.Instance.GetPokemonName(PokemonId); var form = Translator.Instance.GetFormName(Form); var evo = Translator.Instance.GetEvolutionName(Evolution); var gender = Gender.GetPokemonGenderIcon(); var level = Level; var move1 = Translator.Instance.GetMoveName(FastMove); var move2 = Translator.Instance.GetMoveName(ChargeMove); var types = pkmnInfo?.Types; var type1 = types?[0]; var type2 = types?.Count > 1 ? types?[1] : PokemonType.None; var type1Emoji = types?[0].GetTypeEmojiIcons(); var type2Emoji = pkmnInfo?.Types?.Count > 1 ? types?[1].GetTypeEmojiIcons() : string.Empty; var typeEmojis = $"{type1Emoji} {type2Emoji}"; var weaknesses = Weaknesses == null ? string.Empty : string.Join(", ", Weaknesses); var weaknessesEmoji = types?.GetWeaknessEmojiIcons(); var perfectRange = PokemonId.MaxCpAtLevel(20); var boostedRange = PokemonId.MaxCpAtLevel(25); var worstRange = PokemonId.MinCpAtLevel(20); var worstBoosted = PokemonId.MinCpAtLevel(25); var exEmojiId = MasterFile.Instance.Emojis["ex"]; var exEmoji = exEmojiId > 0 ? $"<:ex:{exEmojiId}>" : "EX"; var teamEmojiId = MasterFile.Instance.Emojis[Team.ToString().ToLower()]; var teamEmoji = teamEmojiId > 0 ? $"<:{Team.ToString().ToLower()}:{teamEmojiId}>" : Team.ToString(); var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var templatePath = Path.Combine(whConfig.StaticMaps.TemplatesFolder, whConfig.StaticMaps.Raids.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, whConfig.Urls.StaticMap, whConfig.StaticMaps.Raids.ZoomLevel, Latitude, Longitude, raidImageUrl, Team); var gmapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? gmapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? appleMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? wazeMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? scannerMapsLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); Geofence.Location address = null; if (!string.IsNullOrEmpty(whConfig.GoogleMapsKey)) { address = Utils.GetGoogleAddress(city, Latitude, Longitude, whConfig.GoogleMapsKey); } else if (!string.IsNullOrEmpty(whConfig.NominatimEndpoint)) { address = Utils.GetNominatimAddress(city, Latitude, Longitude, whConfig.NominatimEndpoint); } //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Raid boss properties { "pkmn_id", PokemonId.ToString() }, { "pkmn_id_3", PokemonId.ToString("D3") }, { "pkmn_name", name }, { "pkmn_img_url", raidImageUrl }, { "evolution", evo }, { "evolution_id", Convert.ToInt32(Evolution).ToString() }, { "evolution_id_3", Evolution.ToString("D3") }, { "form", form }, { "form_id", Form.ToString() }, { "form_id_3", Form.ToString("D3") }, { "is_egg", Convert.ToString(IsEgg) }, { "is_ex", Convert.ToString(IsExEligible) }, { "ex_emoji", exEmoji }, { "team", Team.ToString() }, { "team_id", Convert.ToInt32(Team).ToString() }, { "team_emoji", teamEmoji }, { "cp", CP ?? defaultMissingValue }, { "lvl", level ?? defaultMissingValue }, { "gender", gender ?? defaultMissingValue }, { "move_1", move1 ?? defaultMissingValue }, { "move_2", move2 ?? defaultMissingValue }, { "moveset", $"{move1}/{move2}" }, { "type_1", type1?.ToString() ?? defaultMissingValue }, { "type_2", type2?.ToString() ?? defaultMissingValue }, { "type_1_emoji", type1Emoji }, { "type_2_emoji", type2Emoji }, { "types", $"{type1}/{type2}" }, { "types_emoji", typeEmojis }, { "weaknesses", weaknesses }, { "weaknesses_emoji", weaknessesEmoji }, { "perfect_cp", perfectRange.ToString() }, { "perfect_cp_boosted", boostedRange.ToString() }, { "worst_cp", worstRange.ToString() }, { "worst_cp_boosted", worstBoosted.ToString() }, //Time properties { "start_time", StartTime.ToLongTimeString() }, { "start_time_24h", StartTime.ToString("HH:mm:ss") }, { "start_time_left", DateTime.Now.GetTimeRemaining(StartTime).ToReadableStringNoSeconds() }, { "end_time", EndTime.ToLongTimeString() }, { "end_time_24h", EndTime.ToString("HH:mm:ss") }, { "end_time_left", EndTime.GetTimeRemaining().ToReadableStringNoSeconds() }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Math.Round(Latitude, 5).ToString() }, { "lng_5", Math.Round(Longitude, 5).ToString() }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, //Gym properties { "gym_id", GymId }, { "gym_name", GymName }, { "gym_url", GymUrl }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, GymDetailsData oldGym) { var exEmojiId = MasterFile.Instance.Emojis["ex"]; var exEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis["ex"]) ? exEmojiId > 0 ? string.Format(Strings.EmojiSchema, "ex", exEmojiId): "EX" : MasterFile.Instance.CustomEmojis["ex"]; var teamEmojiId = MasterFile.Instance.Emojis[Team.ToString().ToLower()]; var teamEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[Team.ToString().ToLower()]) ? teamEmojiId > 0 ? string.Format(Strings.EmojiSchema, Team.ToString().ToLower(), teamEmojiId) : Team.ToString() : MasterFile.Instance.CustomEmojis[Team.ToString().ToLower()]; var oldTeamEmojiId = MasterFile.Instance.Emojis[oldGym?.Team.ToString().ToLower()]; var oldTeamEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[oldGym?.Team.ToString().ToLower()]) ? oldTeamEmojiId > 0 ? string.Format(Strings.EmojiSchema, oldGym?.Team.ToString().ToLower(), oldTeamEmojiId) : oldGym?.Team.ToString() : MasterFile.Instance.CustomEmojis[oldGym.Team.ToString().ToLower()]; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var templatePath = Path.Combine(whConfig.StaticMaps.TemplatesFolder, whConfig.StaticMaps.Gyms.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, whConfig.Urls.StaticMap, whConfig.StaticMaps.Gyms.ZoomLevel, Latitude, Longitude, /*TODO: Add team image*/ string.Empty, Team); //var staticMapLink = string.Format(whConfig.Urls.StaticMap, Latitude, Longitude);//whConfig.Urls.StaticMap.Gyms.Enabled ? string.Format(whConfig.Urls.StaticMap.Gyms.Url, Latitude, Longitude) : string.Empty var gmapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? gmapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? appleMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? wazeMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? scannerMapsLink : UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); Geofence.Location address = null; if (!string.IsNullOrEmpty(whConfig.GoogleMapsKey)) { address = Utils.GetGoogleAddress(city, Latitude, Longitude, whConfig.GoogleMapsKey); } else if (!string.IsNullOrEmpty(whConfig.NominatimEndpoint)) { address = Utils.GetNominatimAddress(city, Latitude, Longitude, whConfig.NominatimEndpoint); } //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "gym_id", GymId }, { "gym_name", GymName }, { "gym_url", Url }, { "gym_team", Team.ToString() }, { "gym_team_id", Convert.ToInt32(Team).ToString() }, { "gym_team_emoji", teamEmoji }, { "old_gym_team", oldGym.Team.ToString() }, { "old_gym_team_id", Convert.ToInt32(oldGym.Team).ToString() }, { "old_gym_team_emoji", oldTeamEmoji }, { "team_changed", Convert.ToString(oldGym?.Team != Team) }, { "in_battle", Convert.ToString(InBattle) }, { "under_attack", Convert.ToString(InBattle) }, { "is_ex", Convert.ToString(SponsorId) }, { "ex_emoji", exEmoji }, { "slots_available", SlotsAvailable == 0 ? "Full" : SlotsAvailable == 6 ? "Empty" : SlotsAvailable.ToString("N0") }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Math.Round(Latitude, 5).ToString() }, { "lng_5", Math.Round(Longitude, 5).ToString() }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }