private async Task ImportEnergyCardsFromSet(object arg) { using (var client = new WebClient()) { var json = await client.DownloadStringTaskAsync($"https://api.pokemontcg.io/v1/cards?setCode={SelectedSet.SetCode}&supertype=Energy").ConfigureAwait(false); var headers = client.ResponseHeaders; int cardsFound = int.Parse(headers.Get("Count")); int pageSize = int.Parse(headers.Get("Page-Size")); if (cardsFound > pageSize) { //TODO } foreach (var card in JsonConvert.DeserializeObject <PokemonTcgSdk.Energy>(json).Cards) { EnergyCards.Add(new EnergyCard() { Name = card.Name, ImageUrl = card.ImageUrlHiRes, SetCode = card.SetCode, IsBasic = card.SubType.ToLower() == "basic", Amount = 1, EnergyType = EnergyTypes.Colorless, CardId = NetworkId.Generate() }); } SelectedEnergyCard = EnergyCards.Last(); } }
private void AddEnergyCard(object obj) { EnergyCards.Add(new EnergyCard() { Name = "New Energy", CardId = NetworkId.Generate() }); SelectedEnergyCard = EnergyCards.Last(); }
private void UpdateSetFilter() { if (SelectedSet == null) { FilteredCards = EnergyCards.ToList(); return; } FilteredCards = EnergyCards.Where(card => card.SetCode == SelectedSet.SetCode).ToList(); }
internal async Task Load() { if (!File.Exists("Data/energy.json")) { return; } var json = await File.ReadAllTextAsync("Data/energy.json"); EnergyCards.Clear(); foreach (var energy in Serializer.Deserialize <List <EnergyCard> >(json)) { EnergyCards.Add(energy); } }