示例#1
0
        public async Task UpdatePokeDex()
        {
            var inventory = await GetCachedInventory();

            var newPokeDex = (from items in inventory?.InventoryDelta.InventoryItems
                              where items.InventoryItemData?.PokedexEntry != null
                              select items).Select(x => x.InventoryItemData.PokedexEntry).ToList();

            foreach (var entry in newPokeDex)
            {
                var dexEntry = PokeDex.FirstOrDefault(x => x.Id == entry.PokemonId);
                if (dexEntry == null)
                {
                    PokeDex.Add(new PokeDexRecord
                    {
                        Id            = entry.PokemonId,
                        SeenTimes     = entry.TimesEncountered,
                        CapturedTimes = entry.TimesCaptured,
                        PokemonName   = _translation.GetPokemonName(entry.PokemonId)
                    });
                }
                else
                {
                    dexEntry.CapturedTimes = entry.TimesCaptured;
                    dexEntry.SeenTimes     = entry.TimesEncountered;
                }
            }
        }