Beispiel #1
0
        internal void Update(IEnumerable <PokemonData> pokemons)
        {
            foreach (var item in pokemons)
            {
                var existing = Pokemons.FirstOrDefault(x => x.Id == item.Id);

                if (existing != null)
                {
                    existing.Displayed = Filter.Check(existing);
                    existing.UpdateWith(item);
                }
                else
                {
                    var pokemonDataViewModel = new PokemonDataViewModel(this.Session, item);
                    pokemonDataViewModel.Displayed = Filter.Check(pokemonDataViewModel);

                    Pokemons.Add(pokemonDataViewModel);
                    Task.Run(async() =>
                    {
                        GeoLocation geoLocation = await GeoLocation.FindOrUpdateInDatabase(pokemonDataViewModel.PokemonData.CapturedCellId);
                        if (geoLocation != null)
                        {
                            pokemonDataViewModel.GeoLocation = geoLocation;
                        }
                    });
                }
            }

            // Remove missing pokemon
            List <PokemonDataViewModel> modelsToRemove = new List <PokemonDataViewModel>();

            foreach (var item in Pokemons)
            {
                var existing = pokemons.FirstOrDefault(x => x.Id == item.Id);
                if (existing == null)
                {
                    modelsToRemove.Add(item);
                }
            }

            foreach (var model in modelsToRemove)
            {
                Pokemons.Remove(model);
            }
        }
Beispiel #2
0
        internal void OnEvolved(PokemonEvolveEvent ev)
        {
            var exist = Get(ev.OriginalId);

            if (exist != null && ev.Result == POGOProtos.Networking.Responses.EvolvePokemonResponse.Types.Result.Success)
            {
                this.Pokemons.Remove(exist);
                var newItem = new PokemonDataViewModel(ev.EvolvedPokemon);
                this.Pokemons.Add(newItem);

                foreach (var item in this.Pokemons)
                {
                    if (item.PokemonSettings != null && item.PokemonSettings.FamilyId == ev.Family?.FamilyId)
                    {
                        item.Candy = ev.Family.Candy_;
                    }
                }
            }
        }
Beispiel #3
0
        internal bool Check(PokemonDataViewModel item)
        {
            if (!string.IsNullOrEmpty(Name))
            {
                if (!Name.ToLower().Contains(item.PokemonId.ToString().ToLower()))
                {
                    return(false);
                }
            }

            if (item.IV < MinIV || item.IV > MaxIV)
            {
                return(false);
            }
            if (item.Level < MinLevel || item.Level > MaxLevel)
            {
                return(false);
            }
            if (item.CP < MinCP || item.CP > MaxCP)
            {
                return(false);
            }
            return(true);
        }