예제 #1
0
        public void LoadTransferSettings()
        {
            TransferSettings = new List <TransferSetting>();

            foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
            {
                if (pokemon == PokemonId.Missingno)
                {
                    continue;
                }

                var setting = new TransferSetting {
                    Id       = pokemon,
                    Transfer = true
                };

                TransferSettings.Add(setting);
            }
        }
        private void UpdateDisplay()
        {
            TransferSetting setting = _settings.First();

            for (int i = 0; i < comboBoxTransferType.Items.Count; i++)
            {
                if (((TransferType)comboBoxTransferType.Items[i]) == setting.Type)
                {
                    comboBoxTransferType.SelectedIndex = i;

                    break;
                }
            }

            numericUpDownKeepMax.Value   = setting.KeepMax;
            numericUpDownMinCP.Value     = setting.MinCP;
            numericUpDownIVPercent.Value = setting.CPPercent;
            checkBoxTransfer.Checked     = setting.Transfer;
        }
예제 #3
0
        public AccountSettingsForm(Manager manager)
        {
            InitializeComponent();

            _manager = manager;

            #region Catching

            olvColumnCatchId.AspectGetter = delegate(object x)
            {
                CatchSetting setting = (CatchSetting)x;

                return((int)setting.Id);
            };

            #endregion

            #region Evolving

            olvColumnEvolveId.AspectGetter = delegate(object x)
            {
                EvolveSetting setting = (EvolveSetting)x;

                return((int)setting.Id);
            };

            #endregion

            #region Transfer

            olvColumnTransferId.AspectGetter = delegate(object x)
            {
                TransferSetting setting = (TransferSetting)x;

                return((int)setting.Id);
            };

            #endregion
        }
예제 #4
0
        private async Task <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
                });
            }

            await UpdatePokemon(false);
            await UpdatePokemonCandy(false);
            await GetItemTemplates();

            if (Pokemon == null || Pokemon.Count == 0)
            {
                LogCaller(new LoggerEventArgs("You have no pokemon", LoggerTypes.Info));

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

            List <PokemonData> pokemonToTransfer = new List <PokemonData>();

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

            foreach (IGrouping <PokemonId, PokemonData> group in groupedPokemon)
            {
                TransferSetting settings = UserSettings.TransferSettings.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.Type)
                {
                case TransferType.All:
                    pokemonToTransfer.AddRange(group.ToList());
                    break;

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

                case TransferType.BelowIVPercentage:
                    pokemonToTransfer.AddRange(GetPokemonBelowIVPercent(group, settings.CPPercent));
                    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.BelowCPOrIVAmount:
                    pokemonToTransfer.AddRange(GetPokemonBelowIVPercent(group, settings.CPPercent));
                    pokemonToTransfer.AddRange(GetPokemonBelowCP(group, settings.MinCP));
                    pokemonToTransfer = pokemonToTransfer.DistinctBy(x => x.Id).ToList();
                    break;
                }
            }

            return(new MethodResult <List <PokemonData> >
            {
                Data = pokemonToTransfer,
                Message = String.Format("Found {0} pokemon to transfer", pokemonToTransfer.Count),
                Success = true
            });
        }
예제 #5
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)
            {
                TransferSetting settings = UserSettings.TransferSettings.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.Type)
                {
                case TransferType.All:
                    pokemonToTransfer.AddRange(group.ToList());
                    break;

                case TransferType.BelowCP:
                    pokemonToTransfer.AddRange(GetPokemonBelowCP(group, settings.MinCP));
                    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.MinCP, settings.IVPercent));
                    break;

                case TransferType.BelowCPOrIVAmount:
                    pokemonToTransfer.AddRange(GetPokemonBelowIVPercent(group, settings.IVPercent));
                    pokemonToTransfer.AddRange(GetPokemonBelowCP(group, settings.MinCP));
                    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
            });
        }