Beispiel #1
0
 public void GotNewPokemon(ulong uid, PokemonId pokemonId, int cp, double iv, PokemonFamilyId family, int candy, bool fav, bool inGym, double level, PokemonMove move1, PokemonMove move2, PokemonType type1, PokemonType type2, int maxCp, int stamina, int maxStamina, int possibleCp, int candyToEvolve)
 {
     PokemonList.Add(new PokemonUiData(
                         this,
                         uid,
                         pokemonId,
                         //pokemonId.ToInventorySource(),
                         pokemonId.ToString(),
                         cp,
                         iv,
                         family,
                         candy,
                         (ulong)DateTime.UtcNow.ToUnixTime(),
                         fav,
                         inGym,
                         level,
                         move1,
                         move2,
                         type1,
                         type2,
                         maxCp,
                         PokemonInfo.GetBaseStats(pokemonId),
                         stamina,
                         maxStamina,
                         possibleCp,
                         candyToEvolve));
     foreach (var pokemon in PokemonList.Where(x => x.Family == family))
     {
         pokemon.Candy = candy;
         pokemon.UpdateTags(Logic);
     }
 }
Beispiel #2
0
        //Generate user friendly pokemon names
        private static string SpellCheckPokemon(PokemonId pokemon)
        {
            string display;

            switch (pokemon)
            {
            case PokemonId.Farfetchd:
                display = "Farfetch'd";
                break;

            case PokemonId.MrMime:
                display = "Mr. Mime";
                break;

            case PokemonId.NidoranFemale:
                display = "Nidoran♀";
                break;

            case PokemonId.NidoranMale:
                display = "Nidoran♂";
                break;

            default:
                display = pokemon.ToString();
                break;
            }
            if (s_config.PokemonOverrides != null && s_config.PokemonOverrides.Any(po => po.Kind == pokemon))
            {
                display = s_config.PokemonOverrides.First(po => po.Kind == pokemon).Display;
            }
            return(display);
        }
Beispiel #3
0
        public static System.Windows.Controls.Image ToImage(this PokemonId pid)
        {
            System.Windows.Controls.Image img = new System.Windows.Controls.Image();
            img.Source = pid.ToBitmap().loadBitmap();
            var tt = new ToolTip();

            tt.Content  = pid.ToString();
            img.ToolTip = tt;
            return(img);
        }
Beispiel #4
0
 public static string getPokemonNameByLanguage(ISettings clientSettings, PokemonId b)
 {
     if (clientSettings.Language)
     {
         return(getPokemonNameGer(b));
     }
     else
     {
         return(b.ToString());
     }
 }
Beispiel #5
0
        public static System.Windows.Controls.Image ToInventoryImage(this PokemonId pid)
        {
            var img = new System.Windows.Controls.Image {
                Source = pid.ToInventoryBitmap().LoadBitmap()
            };
            var tt = new ToolTip {
                Content = pid.ToString()
            };

            img.ToolTip = tt;
            return(img);
        }
        public FilterSetting(PokemonId pokemonId, IPokemonFilter filter, string filterName, Action <PokemonId, IPokemonFilter> onSave)
        {
            this.data  = filter;
            translator = TinyIoCContainer.Current.Resolve <UITranslation>();

            this.Title = string.Format(translator.TransferFilterFormTitle, pokemonId.ToString());

            this.PokemonId    = pokemonId;
            this.FilterName   = filterName;
            this.onSaveFilter = onSave;
            this.DataContext  = data;
            InitializeComponent();
            pnlFilters.Children.Add(BuildObjectForm(filter));
            DisplayListPokemons(filter.AffectToPokemons);
        }
Beispiel #7
0
 public void GotNewPokemon(ulong uid, PokemonId pokemonId, int cp, double iv, PokemonFamilyId family, int candy)
 {
     PokemonList.Add(new PokemonUiData(
                         uid,
                         pokemonId,
                         pokemonId.ToInventorySource(),
                         pokemonId.ToString(),
                         cp,
                         iv,
                         family,
                         candy,
                         (ulong)DateTime.UtcNow.ToUnixTime()));
     foreach (var pokemon in PokemonList.Where(x => x.Family == family))
     {
         pokemon.Candy = candy;
         pokemon.UpdateTags(Logic);
     }
 }
Beispiel #8
0
 private string GetPokemonName(PokemonId pokemonID)
 {
     return(th.TS(pokemonID.ToString()));
 }
Beispiel #9
0
        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 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);
            var googleAddress           = Utils.GetGoogleAddress(city, Latitude, Longitude, whConfig.GoogleMapsKey);
            //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 },
                { "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_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", googleAddress?.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);
        }
Beispiel #10
0
 public static string getPokemonNameByLanguage(ISettings clientSettings, PokemonId b)
 {
     return(b.ToString());
 }
        public static async Task Execute(ISession session, ulong pokemonId, PokemonId evolveToId = PokemonId.Missingno)
        {
            using (var blocker = new BlockableScope(session, BotActions.Envolve))
            {
                if (!await blocker.WaitToRun().ConfigureAwait(false))
                {
                    session.EventDispatcher.Send(new PokemonEvolveEvent
                    {
                        OriginalId = pokemonId,
                        Cancelled  = true
                    });
                    return;
                }

                var all = await session.Inventory.GetPokemons().ConfigureAwait(false);

                var pokemons = all.OrderByDescending(x => x.Cp).ThenBy(n => n.StaminaMax);
                var pokemon  = pokemons.FirstOrDefault(p => p.Id == pokemonId);

                if (pokemon == null)
                {
                    return;
                }

                if (!await session.Inventory.CanEvolvePokemon(pokemon, new Model.Settings.EvolveFilter()
                {
                    EvolveTo = evolveToId.ToString()
                }).ConfigureAwait(false))
                {
                    return;
                }
                ItemId itemToEvolve = ItemId.ItemUnknown;
                var    pkmSetting   = await session.Inventory.GetPokemonSetting(pokemon.PokemonId).ConfigureAwait(false);

                if (evolveToId != PokemonId.Missingno && pkmSetting != null)
                {
                    var evolution = pkmSetting.EvolutionBranch.FirstOrDefault(x => x.Evolution == evolveToId);
                    if (evolution != null)
                    {
                        itemToEvolve = evolution.EvolutionItemRequirement;
                        if (itemToEvolve != ItemId.ItemUnknown && await session.Inventory.GetItemAmountByType(itemToEvolve).ConfigureAwait(false) == 0)
                        {
                            session.EventDispatcher.Send(new PokemonEvolveEvent
                            {
                                OriginalId = pokemonId,
                                Cancelled  = true
                            });
                            return;
                        }
                    }
                }

                var evolveResponse = await session.Client.Inventory.EvolvePokemon(pokemon.Id, itemToEvolve).ConfigureAwait(false);

                session.EventDispatcher.Send(new PokemonEvolveEvent
                {
                    OriginalId     = pokemonId,
                    Id             = pokemon.PokemonId,
                    Exp            = evolveResponse.ExperienceAwarded,
                    UniqueId       = pokemon.Id,
                    Result         = evolveResponse.Result,
                    EvolvedPokemon = evolveResponse.EvolvedPokemonData
                });
            }
        }
Beispiel #12
0
 public PokemonManager(PokemonId pokemonId)
 {
     PokemonId   = pokemonId;
     PokemonName = pokemonId.ToString();
 }
Beispiel #13
0
 public static string getPokemonNameByLanguage(PokemonId b)
 {
     return(b.ToString());
 }
Beispiel #14
0
 //Generate user friendly and hashtag friendly pokemon names
 private static string SpellCheckPokemon(PokemonId pokemon, bool isHashtag = false)
 {
     string display;
     switch (pokemon)
     {
         case PokemonId.Farfetchd:
             display = isHashtag ? "Farfetchd" : "Farfetch'd";
             break;
         case PokemonId.MrMime:
             display = isHashtag ? "MrMime" : "Mr. Mime";
             break;
         case PokemonId.NidoranFemale:
             display = isHashtag ? "Nidoran" : "Nidoran♀";
             break;
         case PokemonId.NidoranMale:
             display = isHashtag ? "Nidoran" : "Nidoran♂";
             break;
         default:
             display = pokemon.ToString();
             break;
     }
     if (s_config.PokemonOverrides.Any(po => po.Kind == pokemon))
     {
         display = s_config.PokemonOverrides.First(po => po.Kind == pokemon).Display;
     }
     Regex regex = new Regex("[^a-zA-Z0-9]");
     return isHashtag ? regex.Replace(display, "") : display;
 }
Beispiel #15
0
 public void Decrease(PokemonId pokemonName)
 {
     Decrease(pokemonName.ToString());
 }
Beispiel #16
0
 public void Increase(PokemonId pokemonName)
 {
     Increase(pokemonName.ToString());
 }
Beispiel #17
0
        private IReadOnlyDictionary <string, string> GetProperties(DiscordClient client, WhConfig whConfig, string city)
        {
            var pkmnInfo = Database.Instance.Pokemon[PokemonId];
            var form     = PokemonId.GetPokemonForm(Form.ToString());
            var gender   = Gender.GetPokemonGenderIcon();
            var level    = Level;
            //var weather = raid.Weather?.ToString();
            //var weatherEmoji = string.Empty;
            //if (raid.Weather.HasValue && Strings.WeatherEmojis.ContainsKey(raid.Weather.Value) && raid.Weather != WeatherType.None)
            //{
            //    var isWeatherBoosted = pkmnInfo.IsWeatherBoosted(raid.Weather.Value);
            //    var isWeatherBoostedText = isWeatherBoosted ? " (Boosted)" : null;
            //    weatherEmoji = Strings.WeatherEmojis[raid.Weather.Value] + isWeatherBoostedText;
            //}
            var move1 = string.Empty;
            var move2 = string.Empty;

            if (MasterFile.Instance.Movesets.ContainsKey(FastMove))
            {
                move1 = MasterFile.Instance.Movesets[FastMove].Name;
            }
            if (MasterFile.Instance.Movesets.ContainsKey(ChargeMove))
            {
                move2 = MasterFile.Instance.Movesets[ChargeMove].Name;
            }
            var type1      = pkmnInfo?.Types?[0];
            var type2      = pkmnInfo?.Types?.Count > 1 ? pkmnInfo?.Types?[1] : PokemonType.None;
            var type1Emoji = client.Guilds.ContainsKey(whConfig.Discord.EmojiGuildId) ?
                             pkmnInfo?.Types?[0].GetTypeEmojiIcons(client.Guilds[whConfig.Discord.EmojiGuildId]) :
                             string.Empty;
            var type2Emoji = client.Guilds.ContainsKey(whConfig.Discord.EmojiGuildId) && pkmnInfo?.Types?.Count > 1 ?
                             pkmnInfo?.Types?[1].GetTypeEmojiIcons(client.Guilds[whConfig.Discord.EmojiGuildId]) :
                             string.Empty;
            var typeEmojis      = $"{type1Emoji} {type2Emoji}";
            var weaknesses      = Weaknesses == null ? string.Empty : string.Join(", ", Weaknesses);
            var weaknessesEmoji = client.Guilds.ContainsKey(whConfig.Discord.EmojiGuildId) ?
                                  Weaknesses.GetWeaknessEmojiIcons(client.Guilds[whConfig.Discord.EmojiGuildId]) :
                                  string.Empty;
            var weaknessesEmojiFormatted = weaknessesEmoji;
            var perfectRange             = PokemonId.MaxCpAtLevel(20);
            var boostedRange             = PokemonId.MaxCpAtLevel(25);
            var worstRange   = PokemonId.MinCpAtLevel(20);
            var worstBoosted = PokemonId.MinCpAtLevel(25);
            var exEmojiId    = client.Guilds.ContainsKey(whConfig.Discord.EmojiGuildId) ?
                               client.Guilds[whConfig.Discord.EmojiGuildId].GetEmojiId("ex") :
                               0;
            var exEmoji     = exEmojiId > 0 ? $"<:ex:{exEmojiId}>" : "EX";
            var teamEmojiId = client.Guilds.ContainsKey(whConfig.Discord.EmojiGuildId) ?
                              client.Guilds[whConfig.Discord.EmojiGuildId].GetEmojiId(Team.ToString().ToLower()) :
                              0;
            var teamEmoji = teamEmojiId > 0 ? $"<:{Team.ToString().ToLower()}:{teamEmojiId}>" : Team.ToString();

            var pkmnImage             = IsEgg ? string.Format(whConfig.Urls.EggImage, Level) : PokemonId.GetPokemonImage(whConfig.Urls.PokemonImage, PokemonGender.Unset, Form);
            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 staticMapLink         = Utils.PrepareStaticMapUrl(whConfig.Urls.StaticMap, pkmnImage, Latitude, Longitude);
            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 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_name", pkmnInfo.Name },
                { "pkmn_img_url", pkmnImage },
                { "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_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", weaknessesEmojiFormatted },
                { "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_left", DateTime.Now.GetTimeRemaining(StartTime).ToReadableStringNoSeconds() },
                { "end_time", EndTime.ToLongTimeString() },
                { "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 },

                //Gym properties
                { "gym_id", GymId },
                { "gym_name", GymName },
                { "gym_url", GymUrl },

                //Misc properties
                { "br", "\r\n" }
            };

            return(dict);
        }
 public PokemonToggle(PokemonId id, bool isChecked)
 {
     Name = id.ToString();
     Id = id;
     Numeric = (int)id;
     IsChecked = isChecked;
 }
Beispiel #19
0
        public static string getPokemonNameByLanguage(ISettings clientSettings, PokemonId b)
        {
            if (clientSettings.Language)
            {
                return getPokemonNameGer(b);

            }
            else
            {
                return b.ToString();
            }
        }