private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;
            try
            {
                Pokemon.Clear();
                var pokemon = await DataStore.GetItemsAsync(true);

                foreach (var poke in pokemon)
                {
                    Pokemon temp = poke;
                    temp.name = UppercaseFirst(temp.name);
                    Pokemon.Add(temp);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async void PopulatePokemon(IEnumerable <Pokemon> source = null)
        {
            IsLoading = true;

            if (source == null)
            {
                _pokemon = await _pokeApiService.GetPokemonAsync();
            }
            else
            {
                _pokemon = source;
            }

            Pokemon.Clear();

            foreach (var p in _pokemon)
            {
                Pokemon.Add(p);
            }

            IsLoading = false;
        }
Beispiel #3
0
        /// <summary>
        /// Load Inventory methodes.
        /// </summary>
        public void UpdateInventory(InventoryRefresh type)
        {
            if (!_client.LoggedIn)
            {
                return;
            }

            LogCaller(new LoggerEventArgs($"Updating inventory. Items to load: {type}", LoggerTypes.Debug));

            try
            {
                foreach (var item in _client.ClientSession.Player.Inventory.InventoryItems)
                {
                    AddRemoveOrUpdateItem(item);
                }

                switch (type)
                {
                case InventoryRefresh.All:
                    Items.Clear();
                    Pokemon.Clear();
                    Pokedex.Clear();
                    PokemonCandy.Clear();
                    Incubators.Clear();
                    Eggs.Clear();
                    Stats        = GetPlayerStats();
                    Items        = GetItemsData().ToList();
                    Pokedex      = GetPokedex().ToList();
                    PokemonCandy = GetCandies().ToList();
                    Incubators   = GetIncubators().ToList();
                    Eggs         = GetEggs().ToList();
                    Pokemon      = GetPokemons().ToList();
                    break;

                case InventoryRefresh.Items:
                    Items.Clear();
                    Items = GetItemsData().ToList();
                    break;

                case InventoryRefresh.Pokemon:
                    Pokemon.Clear();
                    Pokemon = GetPokemons().ToList();
                    break;

                case InventoryRefresh.Pokedex:
                    Pokedex.Clear();
                    Pokedex = GetPokedex().ToList();
                    break;

                case InventoryRefresh.PokemonCandy:
                    PokemonCandy.Clear();
                    PokemonCandy = GetCandies().ToList();
                    break;

                case InventoryRefresh.Incubators:
                    Incubators.Clear();
                    Incubators = GetIncubators().ToList();
                    break;

                case InventoryRefresh.Eggs:
                    Eggs.Clear();
                    Eggs = GetEggs().ToList();
                    break;

                case InventoryRefresh.Stats:
                    Stats = GetPlayerStats();
                    break;
                }
            }
            catch (Exception ex1)
            {
                LogCaller(new LoggerEventArgs(String.Format("Failed updating inventory."), LoggerTypes.Exception, ex1));
                ++_failedInventoryReponses;
            }
        }
Beispiel #4
0
        public void UpdateInventory()
        {
            LogCaller(new LoggerEventArgs("Updating inventory.", LoggerTypes.Debug));

            try
            {
                var inventoryItems = _client?.ClientSession?.Player?.Inventory?.InventoryItems;
                if (inventoryItems == null)
                {
                    return;
                }
                Items.Clear();
                Pokemon.Clear();
                Pokedex.Clear();
                PokemonCandy.Clear();
                Incubators.Clear();
                Eggs.Clear();
                foreach (var inventoryItem in inventoryItems)
                {
                    if (inventoryItem.InventoryItemData?.PlayerStats != null)
                    {
                        Stats = inventoryItem.InventoryItemData.PlayerStats;
                    }
                    if (inventoryItem.InventoryItemData?.Item != null)
                    {
                        Items.Add(inventoryItem.InventoryItemData.Item);
                    }
                    if (inventoryItem.InventoryItemData?.PokedexEntry != null)
                    {
                        Pokedex.Add(inventoryItem.InventoryItemData.PokedexEntry);
                    }
                    if (inventoryItem.InventoryItemData?.Candy != null)
                    {
                        PokemonCandy.Add(inventoryItem.InventoryItemData.Candy);
                    }
                    if (inventoryItem.InventoryItemData?.EggIncubators != null)
                    {
                        foreach (var eggIncubator in inventoryItem.InventoryItemData.EggIncubators.EggIncubator)
                        {
                            if (eggIncubator != null)
                            {
                                Incubators.Add(eggIncubator);
                            }
                        }
                    }
                    if (inventoryItem.InventoryItemData?.PokemonData != null)
                    {
                        if (inventoryItem.InventoryItemData.PokemonData.IsEgg)
                        {
                            Eggs.Add(inventoryItem.InventoryItemData.PokemonData);
                        }
                        else
                        {
                            Pokemon.Add(inventoryItem.InventoryItemData.PokemonData);
                        }
                    }
                }
            }
            catch (Exception ex1)
            {
                AccountState = Enums.AccountState.TemporalBan;
                LogCaller(new LoggerEventArgs(String.Format("Failed updating inventory."), LoggerTypes.Debug, ex1));
                Stop();
            }
        }