Ejemplo n.º 1
0
        public void Execute()
        {
            EnabledButton(false, th.TS("Reloading Pokemon list."));
            try
            {
                client = Logic.Logic.objClient;
                if (client.ReadyToUse != false)
                {
                    RandomHelper.RandomSleep(1000, 1200);
                    refreshData();

                    pokemons =
                        inventory.InventoryDelta.InventoryItems
                        .Select(i => i.InventoryItemData?.PokemonData)
                        .Where(p => p != null && p?.PokemonId > 0)
                        .OrderByDescending(key => key.Cp);


                    var families = inventory.InventoryDelta.InventoryItems
                                   .Select(i => i.InventoryItemData?.Candy)
                                   .Where(p => p != null && (int)p?.FamilyId > 0)
                                   .OrderByDescending(p => (int)p.FamilyId);

                    var myPokemonSettings = templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                    var pokemonSettings   = myPokemonSettings.ToList();

                    var myPokemonFamilies = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Candy).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                    var pokemonFamilies   = myPokemonFamilies.ToArray();
                    try{
                        PokemonListView.BeginUpdate();
                    }catch (Exception ex1) {
                        Logger.ExceptionInfo(ex1.ToString());
                    }

                    PokemonListView.Items.Clear();

                    foreach (var pokemon in pokemons)
                    {
                        var listViewItem = new ListViewItem();
                        listViewItem.UseItemStyleForSubItems = false;

                        listViewItem.Tag = pokemon;
                        var currentCandy = families
                                           .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                                           .Select(f => f.Candy_)
                                           .First();
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));
                        if (checkBox_ShortName.Checked)
                        {
                            listViewItem.SubItems.Add(string.Format("{0}% {1}{2}{3} ({4})", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack.ToString("X"), pokemon.IndividualDefense.ToString("X"), pokemon.IndividualStamina.ToString("X"), (45 - pokemon.IndividualAttack - pokemon.IndividualDefense - pokemon.IndividualStamina)));
                        }
                        else
                        {
                            listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                        }
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.GetLevel(pokemon)));
                        listViewItem.ImageKey = pokemon.PokemonId.ToString();
                        var specSymbol = "";
                        if (pokemon.Favorite == 1)
                        {
                            specSymbol = "★";
                        }
                        if ((profile != null) && (profile.PlayerData.BuddyPokemon.Id == pokemon.Id))
                        {
                            specSymbol = "☉";
                        }
                        listViewItem.Text = specSymbol + th.TS(pokemon.PokemonId.ToString());


                        listViewItem.ToolTipText = StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "dd/MM/yyyy HH:mm:ss");
                        if (pokemon.Nickname != "")
                        {
                            listViewItem.ToolTipText += th.TS("\n+Nickname: {0}", pokemon.Nickname);
                        }

                        # region Evolve Column
                        var settings    = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                        var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);
                        listViewItem.SubItems.Add("");
                        var    numOfEvolves = 0;
                        String strEvolves   = EvolvesToString(pokemon, settings, familyCandy, out numOfEvolves);
                        // Colour Management
                        listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.DarkRed;
                        if (numOfEvolves == 1)
                        {
                            listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.ForestGreen;
                        }
                        else if (numOfEvolves > 1)
                        {
                            listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.LightPink;
                        }
                        listViewItem.SubItems[listViewItem.SubItems.Count - 1].Text = $"{strEvolves} | C:{familyCandy.Candy_}";
                        # endregion Evolve Column

                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.HeightM, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.WeightKg, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}/{1}", pokemon.Stamina, pokemon.StaminaMax));
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move1));
                        listViewItem.SubItems.Add(string.Format("{0} ({1})", pokemon.Move2, PokemonInfo.GetAttack(pokemon.Move2)));
                        listViewItem.SubItems.Add(string.Format("{0}", (int)pokemon.PokemonId));
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.CalculatePokemonPerfectionCP(pokemon).ToString("0.00")));

                        AdditionalPokeData addData = additionalPokeData.FirstOrDefault(x => x.PokedexNumber == (int)pokemon.PokemonId);
                        if (addData != null)
                        {
                            listViewItem.SubItems.Add(addData.Type1);
                            listViewItem.SubItems.Add(addData.Type2);
                        }
                        else
                        {
                            listViewItem.SubItems.Add("");
                            listViewItem.SubItems.Add("");
                        }
                        // NOTE: yyyy/MM/dd is inverted order to can sort correctly as text.
                        listViewItem.SubItems.Add(Logic.Utils.StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "yyyy/MM/dd HH:mm:ss"));
                        listViewItem.SubItems.Add(th.TS(pokemon.Pokeball.ToString().Replace("Item", "")));
                        listViewItem.SubItems.Add("" + pokemon.NumUpgrades);
                        listViewItem.SubItems.Add("" + pokemon.BattlesAttacked);
                        listViewItem.SubItems.Add("" + pokemon.BattlesDefended);
                        listViewItem.SubItems.Add("" + pokemon.DeployedFortId);
                        if (pokemon.DeployedFortId != "")
                        {
                            listViewItem.SubItems[0].BackColor = Color.Bisque;
                        }

                        var CapturedLatlng = S2Helper.GetLatLng(pokemon.CapturedCellId);
                        listViewItem.SubItems.Add(Logic.Utils.LocationUtils.FindAddress(CapturedLatlng[0], CapturedLatlng[1]));

                        PokemonListView.Items.Add(listViewItem);
                    }
                    try{
                        PokemonListView.EndUpdate();
                    }catch (Exception ex1) {
                        Logger.ExceptionInfo(ex1.ToString());
                    }
                    PokemonListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    EnabledButton(true);
                    statusTexbox.Text = string.Empty;
                    RefreshTitle();
                    if (playerPanel1 != null)
                    {
                        playerPanel1.SetPokemons(pokemons);
                    }
                }
Ejemplo n.º 2
0
        public void Execute()
        {
            EnabledButton(false, th.TS("Reloading Pokemon list."));
            try
            {
                client = Logic.Logic.objClient;
                if (client.ReadyToUse)
                {
                    RandomHelper.RandomSleep(1000, 1200);

                    var pokemons        = client.Inventory.GetPokemons();
                    var pokemonSettings = Setout.GetPokemonSettings();
                    var pokemonFamilies = Setout.GetPokemonFamilies();
                    var profile         = client.Player;

                    try{
                        PokemonListView.BeginUpdate();
                    }catch (Exception ex1) {
                        Logger.ExceptionInfo(ex1.ToString());
                    }

                    PokemonListView.Items.Clear();

                    foreach (var pokemon in pokemons)
                    {
                        var listViewItem = new ListViewItem();
                        listViewItem.UseItemStyleForSubItems = false;

                        listViewItem.Tag = pokemon;
                        var currentCandy = pokemonFamilies
                                           .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                                           .Select(f => f.Candy_)
                                           .First();

                        var specSymbol = "";
                        if (pokemon.Favorite == 1)
                        {
                            specSymbol = "★";
                        }

                        if ((profile.PlayerResponse.PlayerData.BuddyPokemon != null) && (profile.PlayerResponse.PlayerData.BuddyPokemon.Id == pokemon.Id))
                        {
                            specSymbol = "☉";
                        }
                        listViewItem.Text = specSymbol + th.TS(pokemon.PokemonId.ToString());


                        listViewItem.ToolTipText = StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "dd/MM/yyyy HH:mm:ss");
                        if (pokemon.Nickname != "")
                        {
                            listViewItem.ToolTipText += th.TS("\n+Nickname: {0}", pokemon.Nickname);
                        }

                        var isbad = (pokemon.IsBad)?"Yes":"No";
                        listViewItem.SubItems.Add("" + isbad);

                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));

                        if (checkBox_ShortName.Checked)
                        {
                            listViewItem.SubItems.Add(string.Format("{0}% {1}{2}{3} ({4})", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack.ToString("X"), pokemon.IndividualDefense.ToString("X"), pokemon.IndividualStamina.ToString("X"), (45 - pokemon.IndividualAttack - pokemon.IndividualDefense - pokemon.IndividualStamina)));
                        }
                        else
                        {
                            listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                        }
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.GetLevel(pokemon)));

                        # region Evolve Column
                        var settings    = pokemonSettings.FirstOrDefault(x => x.PokemonId == pokemon.PokemonId);
                        var familyCandy = pokemonFamilies.FirstOrDefault(x => x.FamilyId == settings.FamilyId);
                        listViewItem.SubItems.Add("");
                        var    numOfEvolves = 0;
                        String strEvolves   = EvolvesToString(pokemon, settings, familyCandy, out numOfEvolves);
                        // Colour Management
                        listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.DarkRed;
                        if (numOfEvolves == 1)
                        {
                            listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.ForestGreen;
                        }
                        else if (numOfEvolves > 1)
                        {
                            listViewItem.SubItems[listViewItem.SubItems.Count - 1].ForeColor = Color.LightPink;
                        }
                        listViewItem.SubItems[listViewItem.SubItems.Count - 1].Text = $"{strEvolves} | C:{familyCandy.Candy_}";
                        # endregion Evolve Column

                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.HeightM, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.WeightKg, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}/{1}", pokemon.Stamina, pokemon.StaminaMax));
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move1));
                        listViewItem.SubItems.Add(string.Format("{0} ({1})", pokemon.Move2, PokemonInfo.GetAttack(pokemon.Move2)));
                        listViewItem.SubItems.Add(string.Format("{0}", (int)pokemon.PokemonId));
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.CalculatePokemonPerfectionCP(pokemon).ToString("0.00")));

                        AdditionalPokeData addData = additionalPokeData.FirstOrDefault(x => x.PokedexNumber == (int)pokemon.PokemonId);
                        if (addData != null)
                        {
                            listViewItem.SubItems.Add(addData.Type1);
                            listViewItem.SubItems.Add(addData.Type2);
                        }
                        else
                        {
                            listViewItem.SubItems.Add("");
                            listViewItem.SubItems.Add("");
                        }
                        // NOTE: yyyy/MM/dd is inverted order to can sort correctly as text.
                        listViewItem.SubItems.Add(StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "yyyy/MM/dd HH:mm:ss"));
                        listViewItem.SubItems.Add(th.TS(pokemon.Pokeball.ToString().Replace("Item", "")));
                        listViewItem.SubItems.Add("" + pokemon.NumUpgrades);
                        listViewItem.SubItems.Add("" + pokemon.BattlesAttacked);
                        listViewItem.SubItems.Add("" + pokemon.BattlesDefended);
                        listViewItem.SubItems.Add("" + pokemon.DeployedFortId);
                        if (pokemon.DeployedFortId != "")
                        {
                            listViewItem.SubItems[0].BackColor = Color.Bisque;
                        }

                        var CapturedLatlng = S2Helper.GetLatLng(pokemon.CapturedCellId);
                        listViewItem.SubItems.Add(LocationUtils.FindAddress(CapturedLatlng[0], CapturedLatlng[1]));
                        listViewItem.SubItems.Add("" + pokemon.PokemonDisplay.Gender);
                        var str = "";
                        if (pokemon.PokemonDisplay.Costume != Costume.Unset)
                        {
                            str = pokemon.PokemonDisplay.Costume.ToString();
                        }
                        listViewItem.SubItems.Add("" + str);
                        var form = "";
                        if (pokemon.PokemonDisplay.Form != POGOProtos.Enums.Form.Unset)
                        {
                            form = pokemon.PokemonDisplay.Form.ToString().Replace("Unown", "").Replace("ExclamationPoint", "!").Replace("QuestionMark", "?");
                        }
                        listViewItem.SubItems.Add("" + form);

                        var shiny = (pokemon.PokemonDisplay.Shiny)?"Yes":"No";
                        listViewItem.SubItems.Add("" + shiny);

                        listViewItem.SubItems.Add("" + pokemon.BuddyCandyAwarded);
                        listViewItem.SubItems.Add("" + pokemon.BuddyTotalKmWalked);
                        listViewItem.SubItems.Add("" + pokemon.Id.ToString("X"));

                        var special = "";
                        if (GlobalVars.UseSpritesFolder)
                        {
                            if (pokemon.PokemonId == PokemonId.Unown)
                            {
                                special = form.ToLower();
                            }
                            else if (shiny == "Yes")
                            {
                                special = "s";
                            }
                            else if (pokemon.PokemonDisplay.Costume != Costume.Unset)
                            {
                                special = pokemon.PokemonDisplay.Costume.ToString().ToLower();
                            }
                        }

                        listViewItem.ImageKey = pokemon.PokemonId + special;

                        PokemonListView.Items.Add(listViewItem);
                    }
                    try{
                        PokemonListView.EndUpdate();
                    }catch (Exception ex1) {
                        Logger.ExceptionInfo(ex1.ToString());
                    }
                    PokemonListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    EnabledButton(true);
                    statusTexbox.Text = string.Empty;
                    RefreshTitle();
                }
Ejemplo n.º 3
0
        private async void Execute()
        {
            EnabledButton(false, "Reloading Pokemon list.");


            await check();

            try
            {
                client = Logic.Logic._client;
                if (client.readyToUse != false)
                {
                    profile = await client.Player.GetPlayer();

                    inventory = await client.Inventory.GetInventory();

                    pokemons =
                        inventory.InventoryDelta.InventoryItems
                        .Select(i => i.InventoryItemData?.PokemonData)
                        .Where(p => p != null && p?.PokemonId > 0)
                        .OrderByDescending(key => key.Cp);
                    var families = inventory.InventoryDelta.InventoryItems
                                   .Select(i => i.InventoryItemData?.Candy)
                                   .Where(p => p != null && (int)p?.FamilyId > 0)
                                   .OrderByDescending(p => (int)p.FamilyId);

                    var imageSize = 50;

                    var imageList = new ImageList {
                        ImageSize = new Size(imageSize, imageSize)
                    };
                    PokemonListView.ShowItemToolTips = true;
                    PokemonListView.SmallImageList   = imageList;

                    var templates = await client.Download.GetItemTemplates();

                    var myPokemonSettings = templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                    var pokemonSettings   = myPokemonSettings.ToList();

                    var myPokemonFamilies = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Candy).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                    var pokemonFamilies   = myPokemonFamilies.ToArray();

                    PokemonListView.DoubleBuffered(true);
                    PokemonListView.View = View.Details;

                    ColumnHeader columnheader;
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "Name";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "CP";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "IV A-D-S";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "LVL";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "Evolvable?";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "Height";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "Weight";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "HP";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "Attack";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "SpecialAttack (DPS)";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "#";
                    PokemonListView.Columns.Add(columnheader);
                    columnheader      = new ColumnHeader();
                    columnheader.Text = "% CP";
                    PokemonListView.Columns.Add(columnheader);

                    PokemonListView.BeginUpdate();
                    foreach (var pokemon in pokemons)
                    {
                        Bitmap pokemonImage = null;
                        await Task.Run(() =>
                        {
                            pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                        });

                        imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);

                        PokemonListView.LargeImageList = imageList;
                        var listViewItem = new ListViewItem();
                        listViewItem.Tag = pokemon;



                        var currentCandy = families
                                           .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                                           .Select(f => f.Candy_)
                                           .First();
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));
                        //< listViewItem.SubItems.Add(string.Format("{0}% {1}{2}{3} ({4})", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack.ToString("X"), pokemon.IndividualDefense.ToString("X"), pokemon.IndividualStamina.ToString("X"), (45 - pokemon.IndividualAttack- pokemon.IndividualDefense- pokemon.IndividualStamina) ));
                        listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.GetLevel(pokemon)));
                        listViewItem.ImageKey = pokemon.PokemonId.ToString();

                        listViewItem.Text = string.Format((pokemon.Favorite == 1) ? "{0} ★" : "{0}", StringUtils.getPokemonNameByLanguage(ClientSettings, (PokemonId)pokemon.PokemonId));

                        listViewItem.ToolTipText = new DateTime((long)pokemon.CreationTimeMs * 10000).AddYears(1769).ToString("dd/MM/yyyy HH:mm:ss");
                        if (pokemon.Nickname != "")
                        {
                            listViewItem.ToolTipText += "\nNickname: " + pokemon.Nickname;
                        }

                        var settings    = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                        var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);

                        if (settings.EvolutionIds.Count > 0 && familyCandy.Candy_ >= settings.CandyToEvolve)
                        {
                            listViewItem.SubItems.Add("Y (" + familyCandy.Candy_ + "/" + settings.CandyToEvolve + ")");
                            listViewItem.Checked = true;
                        }
                        else
                        {
                            if (settings.EvolutionIds.Count > 0)
                            {
                                listViewItem.SubItems.Add("N (" + familyCandy.Candy_ + "/" + settings.CandyToEvolve + ")");
                            }
                            else
                            {
                                listViewItem.SubItems.Add("N (" + familyCandy.Candy_ + "/Max)");
                            }
                        }
                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.HeightM, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.WeightKg, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}/{1}", pokemon.Stamina, pokemon.StaminaMax));
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move1));
                        listViewItem.SubItems.Add(string.Format("{0} ({1})", pokemon.Move2, PokemonInfo.GetAttack(pokemon.Move2)));
                        listViewItem.SubItems.Add(string.Format("{0}", (int)pokemon.PokemonId));
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.CalculatePokemonPerfectionCP(pokemon).ToString("0.00")));
                        PokemonListView.Items.Add(listViewItem);
                    }
                    PokemonListView.EndUpdate();
                    PokemonListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    Text = "Pokemon List | User: "******" | Pokemons: " + pokemons.Count() + "/" + profile.PlayerData.MaxPokemonStorage;
                    EnabledButton(true);

                    statusTexbox.Text = string.Empty;
                }
            }
            catch (Exception e)
            {
                Logger.Error("[PokemonList-Error] " + e.StackTrace);
                await Task.Delay(1000); // Lets the API make a little pause, so we dont get blocked

                Execute();
            }
        }
Ejemplo n.º 4
0
        public async void Execute()
        {
            EnabledButton(false, "Reloading Pokemon list.");
            await check();

            try
            {
                client = Logic.Logic.Client;
                if (client.readyToUse != false)
                {
                    await Task.Delay(1000);

                    inventory = await client.Inventory.GetInventory();

                    try
                    {
                        pokemons =
                            inventory.InventoryDelta.InventoryItems
                            .Select(i => i.InventoryItemData?.PokemonData)
                            .Where(p => p != null && p?.PokemonId > 0)
                            .OrderByDescending(key => key.Cp);
                    }
                    catch (Exception)
                    {
                    }

                    var families = inventory.InventoryDelta.InventoryItems
                                   .Select(i => i.InventoryItemData?.Candy)
                                   .Where(p => p != null && (int)p?.FamilyId > 0)
                                   .OrderByDescending(p => (int)p.FamilyId);


                    var templates = await client.Download.GetItemTemplates();

                    var myPokemonSettings = templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                    var pokemonSettings   = myPokemonSettings.ToList();

                    var myPokemonFamilies = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Candy).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                    var pokemonFamilies   = myPokemonFamilies.ToArray();
                    PokemonListView.BeginUpdate();

                    foreach (var pokemon in pokemons)
                    {
                        var listViewItem = new ListViewItem();
                        listViewItem.Tag = pokemon;
                        var currentCandy = families
                                           .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                                           .Select(f => f.Candy_)
                                           .First();
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));
                        //<listViewItem.SubItems.Add(string.Format("{0}% {1}{2}{3} ({4})", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack.ToString("X"), pokemon.IndividualDefense.ToString("X"), pokemon.IndividualStamina.ToString("X"), (45 - pokemon.IndividualAttack- pokemon.IndividualDefense- pokemon.IndividualStamina) ));
                        listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0"), pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.GetLevel(pokemon)));
                        listViewItem.ImageKey = pokemon.PokemonId.ToString();
                        listViewItem.Text     = string.Format((pokemon.Favorite == 1) ? "{0} ★" : "{0}", StringUtils.getPokemonNameByLanguage(ClientSettings, (PokemonId)pokemon.PokemonId));

                        listViewItem.ToolTipText = StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "dd/MM/yyyy HH:mm:ss");
                        if (pokemon.Nickname != "")
                        {
                            listViewItem.ToolTipText += "\nNickname: " + pokemon.Nickname;
                        }

                        var settings    = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                        var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);

                        if (settings.EvolutionIds.Count > 0 && familyCandy.Candy_ >= settings.CandyToEvolve)
                        {
                            listViewItem.SubItems.Add("Y (" + familyCandy.Candy_ + "/" + settings.CandyToEvolve + ")");
                            listViewItem.Checked = true;
                        }
                        else
                        {
                            if (settings.EvolutionIds.Count > 0)
                            {
                                listViewItem.SubItems.Add("N (" + familyCandy.Candy_ + "/" + settings.CandyToEvolve + ")");
                            }
                            else
                            {
                                listViewItem.SubItems.Add("N (" + familyCandy.Candy_ + "/Max)");
                            }
                        }
                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.HeightM, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.WeightKg, 2)));
                        listViewItem.SubItems.Add(string.Format("{0}/{1}", pokemon.Stamina, pokemon.StaminaMax));
                        listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move1));
                        listViewItem.SubItems.Add(string.Format("{0} ({1})", pokemon.Move2, PokemonInfo.GetAttack(pokemon.Move2)));
                        listViewItem.SubItems.Add(string.Format("{0}", (int)pokemon.PokemonId));
                        listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.CalculatePokemonPerfectionCP(pokemon).ToString("0.00")));

                        AdditionalPokeData addData = additionalPokeData.FirstOrDefault(x => x.PokedexNumber == (int)pokemon.PokemonId);
                        if (addData != null)
                        {
                            listViewItem.SubItems.Add(addData.Type1);
                            listViewItem.SubItems.Add(addData.Type2);
                        }
                        else
                        {
                            listViewItem.SubItems.Add("");
                            listViewItem.SubItems.Add("");
                        }
                        // NOTE: yyyy/MM/dd is inverted order to can sort correctly as text.
                        listViewItem.SubItems.Add(StringUtils.ConvertTimeMSinString(pokemon.CreationTimeMs, "yyyy/MM/dd HH:mm:ss"));
                        listViewItem.SubItems.Add(pokemon.Pokeball.ToString().Replace("Item", ""));
                        listViewItem.SubItems.Add("" + pokemon.NumUpgrades);
                        listViewItem.SubItems.Add("" + pokemon.BattlesAttacked);
                        listViewItem.SubItems.Add("" + pokemon.BattlesDefended);

                        PokemonListView.Items.Add(listViewItem);
                    }
                    PokemonListView.EndUpdate();
                    PokemonListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    EnabledButton(true);
                    btnUseLure.Enabled = false;
                    statusTexbox.Text  = string.Empty;
                    RefreshTitle();
                    if (playerPanel1 != null)
                    {
                        playerPanel1.SetPokemons(pokemons);
                    }
                }
            }
            catch (Exception e)
            {
                //Logger.Error("[PokemonList-Error] " + e.StackTrace);
                await Task.Delay(1000); // Lets the API make a little pause, so we dont get blocked

                Execute();
            }
        }