예제 #1
0
        public MethodResult <List <PokemonData> > GetPokemonToUpgrade()
        {
            if (!UserSettings.UpgradePokemon)
            {
                LogCaller(new LoggerEventArgs("Upgrade disabled", LoggerTypes.Debug));

                return(new MethodResult <List <PokemonData> >
                {
                    Data = new List <PokemonData>(),
                    Message = "Upgrade disabled",
                    Success = true
                });
            }

            if (!Pokemon.Any())
            {
                LogCaller(new LoggerEventArgs("You have no pokemon", LoggerTypes.Info));

                return(new MethodResult <List <PokemonData> >
                {
                    Message = "You have no pokemon"
                });
            }

            var pokemonToUpgrade = new List <PokemonData>();

            IEnumerable <IGrouping <PokemonId, PokemonData> > groupedPokemon = Pokemon.GroupBy(x => x.PokemonId);

            foreach (IGrouping <PokemonId, PokemonData> group in groupedPokemon)
            {
                UpgradeSetting settings = UserSettings.UpgradeSettings.FirstOrDefault(x => x.Id == group.Key);

                if (settings == null)
                {
                    LogCaller(new LoggerEventArgs(String.Format("Failed to find upgrade settings for pokemon {0}", group.Key), LoggerTypes.Warning));

                    continue;
                }

                if (!settings.Upgrade)
                {
                    continue;
                }

                pokemonToUpgrade.AddRange(group.ToList());
            }

            return(new MethodResult <List <PokemonData> >
            {
                Data = pokemonToUpgrade,
                Message = String.Format("Found {0} pokemon to upgrade", pokemonToUpgrade.Count),
                Success = true
            });
        }
예제 #2
0
        public MethodResult <List <PokemonData> > GetPokemonToTransfer()
        {
            if (!UserSettings.TransferPokemon)
            {
                LogCaller(new LoggerEventArgs("Transferring disabled", LoggerTypes.Debug));

                return(new MethodResult <List <PokemonData> >
                {
                    Data = new List <PokemonData>(),
                    Message = "Transferring disabled",
                    Success = true
                });
            }


            if (!Pokemon.Any())
            {
                LogCaller(new LoggerEventArgs("You have no pokemon", LoggerTypes.Info));

                return(new MethodResult <List <PokemonData> > {
                    Message = "You have no pokemon"
                });
            }

            var pokemonToTransfer = new List <PokemonData>();

            IEnumerable <IGrouping <PokemonId, PokemonData> > groupedPokemon = Pokemon.GroupBy(x => x.PokemonId);

            foreach (IGrouping <PokemonId, PokemonData> group in groupedPokemon)
            {
                CatchSetting settings = UserSettings.PokemonSettings.FirstOrDefault(x => x.Id == group.Key);

                if (settings == null)
                {
                    LogCaller(new LoggerEventArgs(String.Format("Failed to find transfer settings for pokemon {0}", group.Key), LoggerTypes.Warning));

                    continue;
                }

                if (!settings.Transfer)
                {
                    continue;
                }

                switch (settings.TransferType)
                {
                case TransferType.All:
                    pokemonToTransfer.AddRange(group.ToList());
                    break;

                case TransferType.BelowCP:
                    pokemonToTransfer.AddRange(GetPokemonBelowCP(group, settings.MinTransferCP));
                    break;

                case TransferType.BelowIVPercentage:
                    pokemonToTransfer.AddRange(GetPokemonBelowIVPercent(group, settings.IVPercent));
                    break;

                case TransferType.KeepPossibleEvolves:
                    pokemonToTransfer.AddRange(GetPokemonByPossibleEvolve(group, settings.KeepMax));
                    break;

                case TransferType.KeepStrongestX:
                    pokemonToTransfer.AddRange(GetPokemonByStrongest(group, settings.KeepMax));
                    break;

                case TransferType.KeepXHighestIV:
                    pokemonToTransfer.AddRange(GetPokemonByIV(group, settings.KeepMax));
                    break;

                case TransferType.BelowCPAndIVAmount:
                    pokemonToTransfer.AddRange(GetPokemonBelowCPIVAmount(group, settings.MinTransferCP, settings.IVPercent));
                    break;

                case TransferType.BelowCPOrIVAmount:
                    pokemonToTransfer.AddRange(GetPokemonBelowIVPercent(group, settings.IVPercent));
                    pokemonToTransfer.AddRange(GetPokemonBelowCP(group, settings.MinTransferCP));
                    pokemonToTransfer = pokemonToTransfer.DistinctBy(x => x.Id).ToList();
                    break;

                case TransferType.Slashed:
                    pokemonToTransfer.AddRange(group.ToList());
                    pokemonToTransfer = pokemonToTransfer.DistinctBy(x => x.IsBad).ToList();
                    break;
                }
            }

            if (UserSettings.TransferSlashPokemons)
            {
                var slashPokemons = Pokemon.Where(x => x.IsBad);
                foreach (var slashPokemon in slashPokemons)
                {
                    var inlist = pokemonToTransfer.FirstOrDefault(x => x.Id == slashPokemon.Id);
                    if (inlist == null)
                    {
                        pokemonToTransfer.Add(slashPokemon);
                    }
                }
            }

            return(new MethodResult <List <PokemonData> >
            {
                Data = pokemonToTransfer,
                Message = String.Format("Found {0} pokemon to transfer", pokemonToTransfer.Count),
                Success = true
            });
        }