Exemplo n.º 1
0
        public void LoadEvolveSettings()
        {
            EvolveSettings = new List <EvolveSetting>();

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

                var setting = new EvolveSetting {
                    Id = pokemon
                };

                EvolveSettings.Add(setting);
            }
        }
Exemplo n.º 2
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
        }
Exemplo n.º 3
0
        private async Task <MethodResult <List <PokemonData> > > GetPokemonToEvolve()
        {
            if (!UserSettings.EvolvePokemon)
            {
                LogCaller(new LoggerEventArgs("Evolving disabled", LoggerTypes.Info));

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

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

            MethodResult result = await GetItemTemplates();

            if (!result.Success)
            {
                LogCaller(new LoggerEventArgs("Failed to grab pokemon settings. Skipping evolution", LoggerTypes.Warning));

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

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

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

            foreach (IGrouping <PokemonId, PokemonData> group in groupedPokemon)
            {
                EvolveSetting evolveSetting = UserSettings.EvolveSettings.FirstOrDefault(x => x.Id == group.Key);

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

                    continue;
                }

                if (!evolveSetting.Evolve)
                {
                    //Don't evolve
                    continue;
                }
                PokemonSettings setting;
                if (!PokeSettings.TryGetValue(group.Key, out setting))
                {
                    LogCaller(new LoggerEventArgs(String.Format("Failed to find settings for pokemon {0}", group.Key), LoggerTypes.Info));

                    continue;
                }

                if (setting.EvolutionIds.Count == 0)
                {
                    //Pokemon can't evolve
                    continue;
                }

                Candy pokemonCandy = PokemonCandy.FirstOrDefault(x => x.FamilyId == setting.FamilyId);
                List <PokemonData> pokemonGroupToEvolve = group.Where(x => x.Cp >= evolveSetting.MinCP).OrderByDescending(x => CalculateIVPerfection(x).Data).ToList();

                if (pokemonCandy == null)
                {
                    LogCaller(new LoggerEventArgs(String.Format("No candy found for pokemon {0}", group.Key), LoggerTypes.Info));

                    continue;
                }

                int candyToEvolve = setting.CandyToEvolve;
                int totalPokemon  = pokemonGroupToEvolve.Count;
                int totalCandy    = pokemonCandy.Candy_;

                int maxPokemon = totalCandy / candyToEvolve;

                foreach (PokemonData pData in pokemonGroupToEvolve.Take(maxPokemon))
                {
                    pokemonToEvolve.Add(pData);
                }
            }

            return(new MethodResult <List <PokemonData> >
            {
                Data = pokemonToEvolve,
                Message = "Success",
                Success = true
            });
        }
Exemplo n.º 4
0
        private MethodResult <List <PokemonData> > GetPokemonToEvolve()
        {
            if (!UserSettings.EvolvePokemon)
            {
                LogCaller(new LoggerEventArgs("Evolving disabled", LoggerTypes.Info));

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

            var pokemonToEvolve = new List <PokemonData>();

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

            foreach (IGrouping <PokemonId, PokemonData> group in groupedPokemon)
            {
                EvolveSetting evolveSetting = UserSettings.EvolveSettings.FirstOrDefault(x => x.Id == group.Key);

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

                    continue;
                }

                if (!evolveSetting.Evolve)
                {
                    //Don't evolve
                    continue;
                }
                PokemonSettings setting;
                if (!PokeSettings.TryGetValue(group.Key, out setting))
                {
                    LogCaller(new LoggerEventArgs(String.Format("Failed to find settings for pokemon {0}", group.Key), LoggerTypes.Info));

                    continue;
                }

                Candy pokemonCandy = PokemonCandy.FirstOrDefault(x => x.FamilyId == setting.FamilyId);
                List <PokemonData> pokemonGroupToEvolve = group.Where(x => x.Cp >= evolveSetting.MinCP).OrderByDescending(x => CalculateIVPerfection(x)).ToList();

                if (pokemonCandy == null)
                {
                    LogCaller(new LoggerEventArgs(String.Format("No candy found for pokemon {0}", group.Key), LoggerTypes.Info));

                    continue;
                }

                int candyToEvolve = setting.EvolutionBranch.Select(x => x.CandyCost).FirstOrDefault();
                int totalPokemon  = pokemonGroupToEvolve.Count;
                int totalCandy    = pokemonCandy.Candy_;

                int maxPokemon = totalCandy / candyToEvolve;

                foreach (PokemonData pData in pokemonGroupToEvolve.Take(maxPokemon))
                {
                    if (!CanTransferOrEvolePokemon(pData, true))
                    {
                        LogCaller(new LoggerEventArgs(String.Format("Skipped {0}, this pokemon cant not be transfered maybe is a favorit, is deployed or is a buddy pokemon.", pData.PokemonId), LoggerTypes.Info));
                    }
                    else
                    {
                        pokemonToEvolve.Add(pData);
                    }
                }
            }

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