public static string GetGenderEmojiIcon(this Gender gender) { var key = $"gender_{gender.ToString().ToLower()}"; var emojiId = MasterFile.Instance.Emojis[key]; var emojiName = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[key]) ? emojiId > 0 ? string.Format(Strings.EmojiSchema, key, emojiId) : gender.ToString() : MasterFile.Instance.CustomEmojis[key]; return(emojiName); }
public static string GetPokemonGenderIcon(this Gender gender) { switch (gender) { case Gender.Male: return("♂"); //♂ \u2642 case Gender.Female: return("♀"); //♀ \u2640 default: return("⚲"); //⚲ } }
public static bool MatchesGender(Gender gender, string desiredGender) { desiredGender = desiredGender.ToLower(); if (desiredGender == "*" || gender == Gender.Less || gender == Gender.Unset) { return(true); } if (desiredGender == "m" && gender == Gender.Male) { return(true); } if (desiredGender == "f" && gender == Gender.Female) { return(true); } return(false); }
private IReadOnlyDictionary <string, string> GetProperties(MessageProperties properties)// 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 != WeatherCondition.None; var isWeatherBoosted = pkmnInfo?.IsWeatherBoosted(Weather ?? WeatherCondition.None); var weatherKey = $"weather_{Convert.ToInt32(Weather ?? WeatherCondition.None)}"; var weatherEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[weatherKey]) ? MasterFile.Instance.CustomEmojis.ContainsKey(weatherKey) && Weather != WeatherCondition.None ? (Weather ?? WeatherCondition.None).GetWeatherEmojiIcon() : string.Empty : MasterFile.Instance.CustomEmojis[weatherKey]; var move1 = int.TryParse(FastMove, out var fastMoveId) ? Translator.Instance.GetMoveName(fastMoveId) : "Unknown"; var move2 = int.TryParse(ChargeMove, out var chargeMoveId) ? Translator.Instance.GetMoveName(chargeMoveId) : "Unknown"; 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(properties.Config.Urls.ScannerMap, Latitude, Longitude); var staticMapLink = StaticMap.GetUrl(properties.Config.Urls.StaticMap, properties.Config.StaticMaps["pokemon"], Latitude, Longitude, properties.ImageUrl); var gmapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, properties.City, Latitude, Longitude).GetAddress(properties.Config); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var pokestop = Pokestop.Pokestops.ContainsKey(PokestopId) ? Pokestop.Pokestops[PokestopId] : null; var greatLeagueEmoji = PvPLeague.Great.GetLeagueEmojiIcon(); var ultraLeagueEmoji = PvPLeague.Ultra.GetLeagueEmojiIcon(); var pvpStats = 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", properties.ImageUrl }, { "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(MatchesGreatLeague) }, { "is_ultra", Convert.ToString(MatchesUltraLeague) }, { "is_pvp", Convert.ToString(MatchesGreatLeague || MatchesUltraLeague) }, //{ "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", properties.City ?? defaultMissingValue }, { "lat", Convert.ToString(Latitude) }, { "lng", Convert.ToString(Longitude) }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, // 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", properties.Guild?.Name }, { "guild_img_url", properties.Guild?.IconUrl }, // Event properties { "is_event", Convert.ToString(IsEvent.HasValue && IsEvent.Value) }, { "date_time", DateTime.Now.ToString() }, // Misc properties { "br", "\r\n" } }; return(dict); }
public string GetPokemonIcon(string style, int pokemonId, int form = 0, int evolution = 0, Gender gender = Gender.Unset, int costume = 0, bool shiny = false) { if (!_availablePokemonForms.ContainsKey(style)) { return(_iconStyles[style] + "pokemon/0.png"); // Substitute Pokemon } var evolutionSuffixes = (evolution > 0 ? new [] { "-e" + evolution, string.Empty } : new [] { string.Empty }).ToList(); var formSuffixes = (form > 0 ? new [] { "-f" + form, string.Empty } : new [] { string.Empty }).ToList(); var costumeSuffixes = (costume > 0 ? new [] { "-c" + costume, string.Empty } : new [] { string.Empty }).ToList(); var genderSuffixes = (gender > 0 ? new [] { "-g" + (int)gender, string.Empty } : new [] { string.Empty }).ToList(); var shinySuffixes = (shiny ? new [] { "-shiny", string.Empty } : new [] { string.Empty }).ToList(); foreach (var evolutionSuffix in evolutionSuffixes) { foreach (var formSuffix in formSuffixes) { foreach (var costumeSuffix in costumeSuffixes) { foreach (var genderSuffix in genderSuffixes) { foreach (var shinySuffix in shinySuffixes) { var result = $"{pokemonId}{evolutionSuffix}{formSuffix}{costumeSuffix}{genderSuffix}{shinySuffix}"; if (_availablePokemonForms[style].Contains(result)) { return(_iconStyles[style] + $"pokemon/{result}.png"); } } } } } } return(_iconStyles[style] + "pokemon/0.png"); // Substitute Pokemon }
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 costume = Translator.Instance.GetCostumeName(Costume); 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 staticMapLink = StaticMap.GetUrl(whConfig.Urls.StaticMap, whConfig.StaticMaps["raids"], Latitude, Longitude, raidImageUrl, Team); var gmapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, city, Latitude, Longitude).GetAddress(whConfig); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var now = DateTime.UtcNow.ConvertTimeFromCoordinates(Latitude, Longitude); var startTimeLeft = now.GetTimeRemaining(StartTime).ToReadableStringNoSeconds(); var endTimeLeft = now.GetTimeRemaining(EndTime).ToReadableStringNoSeconds(); 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") }, { "costume", costume }, { "costume_id", Costume.ToString() }, { "costume_id_3", Costume.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", startTimeLeft }, { "end_time", EndTime.ToLongTimeString() }, { "end_time_24h", EndTime.ToString("HH:mm:ss") }, { "end_time_left", endTimeLeft }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, //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); }
public static bool MatchesGender(Gender gender, Gender desiredGender) { return(gender == desiredGender || gender == Gender.Unset || gender == Gender.Less); }