コード例 #1
0
ファイル: GameClient.cs プロジェクト: ArthurSDev/PoGoIncense
        /// <summary>
        ///     Updates inventory data
        /// </summary>
        public static async Task UpdateInventory()
        {
            // Get ALL the items
            var response = await GetInventory();

            var fullInventory = response.InventoryDelta?.InventoryItems;

            // Update items
            ItemsInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.Item != null)
                                    .GroupBy(item => item.InventoryItemData.Item)
                                    .Select(item => item.First().InventoryItemData.Item), true);
            CatchItemsInventory.AddRange(
                fullInventory.Where(
                    item =>
                    item.InventoryItemData.Item != null && CatchItemIds.Contains(item.InventoryItemData.Item.ItemId))
                .GroupBy(item => item.InventoryItemData.Item)
                .Select(item => item.First().InventoryItemData.Item), true);
            AppliedItems.AddRange(
                fullInventory
                .Where(item => item.InventoryItemData.AppliedItems != null)
                .SelectMany(item => item.InventoryItemData.AppliedItems.Item)
                .Select(item => new AppliedItemWrapper(item)), true);

            // Update incbuators
            IncubatorsInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.EggIncubators != null)
                                         .SelectMany(item => item.InventoryItemData.EggIncubators.EggIncubator)
                                         .Where(item => item != null), true);

            // Update Pokedex
            PokedexInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.PokedexEntry != null)
                                      .Select(item => item.InventoryItemData.PokedexEntry), true);

            // Update Pokemons
            PokemonsInventory.AddRange(fullInventory.Select(item => item.InventoryItemData.PokemonData)
                                       .Where(item => item != null && item.PokemonId > 0), true);
            EggsInventory.AddRange(fullInventory.Select(item => item.InventoryItemData.PokemonData)
                                   .Where(item => item != null && item.IsEgg), true);

            // Update candies
            CandyInventory.AddRange(from item in fullInventory
                                    where item.InventoryItemData?.Candy != null
                                    where item.InventoryItemData?.Candy.FamilyId != PokemonFamilyId.FamilyUnset
                                    group item by item.InventoryItemData?.Candy.FamilyId into family
                                    select new Candy
            {
                FamilyId = family.FirstOrDefault().InventoryItemData.Candy.FamilyId,
                Candy_   = family.FirstOrDefault().InventoryItemData.Candy.Candy_
            }, true);
        }
コード例 #2
0
        /// <summary>
        ///     Updates inventory data
        /// </summary>
        public static async Task UpdateInventory()
        {
            // Get ALL the items
            var fullInventory = (await GetInventory()).InventoryDelta.InventoryItems;

            // Update items
            ItemsInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.Item != null)
                                    .GroupBy(item => item.InventoryItemData.Item)
                                    .Select(item => item.First().InventoryItemData.Item), true);
            CatchItemsInventory.AddRange(
                fullInventory.Where(
                    item =>
                    item.InventoryItemData.Item != null && CatchItemIds.Contains(item.InventoryItemData.Item.ItemId))
                .GroupBy(item => item.InventoryItemData.Item)
                .Select(item => item.First().InventoryItemData.Item), true);

            // Update incbuators
            FreeIncubatorsInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.EggIncubators != null)
                                             .SelectMany(item => item.InventoryItemData.EggIncubators.EggIncubator)
                                             .Where(item => item != null && item.PokemonId == 0), true);
            UsedIncubatorsInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.EggIncubators != null)
                                             .SelectMany(item => item.InventoryItemData.EggIncubators.EggIncubator)
                                             .Where(item => item != null && item.PokemonId != 0), true);

            // Update Pokemons
            PokemonsInventory.AddRange(fullInventory.Select(item => item.InventoryItemData.PokemonData)
                                       .Where(item => item != null && item.PokemonId > 0), true);
            EggsInventory.AddRange(fullInventory.Select(item => item.InventoryItemData.PokemonData)
                                   .Where(item => item != null && item.IsEgg), true);

            // Update Pokedex
            PokedexInventory.AddRange(fullInventory.Where(item => item.InventoryItemData.PokedexEntry != null)
                                      .Select(item => item.InventoryItemData.PokedexEntry), true);

            // Update Player stats
            PlayerStats =
                fullInventory.First(item => item.InventoryItemData.PlayerStats != null).InventoryItemData.PlayerStats;
        }
コード例 #3
0
ファイル: PokedexService.cs プロジェクト: ZunlabResearch/PoGo
        /// <summary>
        /// Gets the PokemonInventory for the current user and loads it into <see cref="PokemonInventory"/>.
        /// </summary>
        /// <returns>A <see cref="Task"/> containing the results of the awaitable call.</returns>
        public async Task GetPokedexInventory()
        {
            var results = await ApiClient.GetPokedexInventoryAsync();

            PokedexInventory.AddRange(results);
        }