示例#1
0
        private async Task <IEnumerable <PokemonData> > GetDuplicatePokemonToTransfer(Client client,
                                                                                      bool keepPokemonsThatCanEvolve)
        {
            var myPokemon = await _pokemonHelper.GetPokemons(client);

            var pokemonList = myPokemon.Where(p => string.IsNullOrEmpty(p.DeployedFortId) | p.DeployedFortId == "0").ToList(); //Don't evolve pokemon in gyms

            if (keepPokemonsThatCanEvolve)
            {
                var results = new List <PokemonData>();
                var pokemonsThatCanBeTransfered = pokemonList.GroupBy(p => p.PokemonId)
                                                  .Where(x => x.Count() > 2).ToList();

                var myPokemonSettings = await _pokemonHelper.GetPokemonSettings(client);

                var pokemonSettings = myPokemonSettings.ToList();

                var myPokemonFamilies = await _pokemonHelper.GetPokemonFamilies(client);

                var pokemonFamilies = myPokemonFamilies.ToArray();

                foreach (var pokemon in pokemonsThatCanBeTransfered)
                {
                    var settings    = pokemonSettings.Single(x => x.PokemonId == pokemon.Key);
                    var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);
                    if (settings.CandyToEvolve == 0)
                    {
                        continue;
                    }

                    var amountToSkip = (familyCandy.Candy_ + settings.CandyToEvolve - 1) / settings.CandyToEvolve + 2;

                    results.AddRange(pokemonList.Where(x => x.PokemonId == pokemon.Key && x.Favorite == 0)
                                     .OrderByDescending(x => x.Cp)
                                     .ThenBy(n => n.StaminaMax)
                                     .Skip(amountToSkip)
                                     .ToList());
                }

                return(results);
            }

            return(pokemonList
                   .GroupBy(p => p.PokemonId)
                   .Where(x => x.Count() > 1)
                   .SelectMany(p => p.Where(x => x.Favorite == 0)
                               .OrderByDescending(x => x.Cp)
                               .ThenBy(n => n.StaminaMax)
                               .Skip(1)
                               .ToList()));
        }
示例#2
0
        private async Task <IEnumerable <PokemonData> > GetPokemonToEvolve(Client client)
        {
            var myPokemons = await _pokemonHelper.GetPokemons(client);

            var pokemons =
                myPokemons.Where(p => string.IsNullOrEmpty(p.DeployedFortId) | p.DeployedFortId == "0").ToList();

            var myPokemonSettings = await _pokemonHelper.GetPokemonSettings(client);

            var pokemonSettings = myPokemonSettings.ToList();

            var myPokemonFamilies = await _pokemonHelper.GetPokemonFamilies(client);

            var pokemonFamilies = myPokemonFamilies.ToArray();

            var pokemonToEvolve = new List <PokemonData>();

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

                //Don't evolve if we can't evolve it
                if (settings.EvolutionIds.Count == 0)
                {
                    continue;
                }

                var pokemonCandyNeededAlready = pokemonToEvolve.Count(p => pokemonSettings
                                                                      .Single(x => x.PokemonId == p.PokemonId)
                                                                      .FamilyId == settings.FamilyId) * settings.CandyToEvolve;

                if (familyCandy.Candy_ - pokemonCandyNeededAlready > settings.CandyToEvolve)
                {
                    pokemonToEvolve.Add(pokemon);
                }
            }

            return(pokemonToEvolve);
        }