public void OpenPacks(IEnumerable <Guid> packs) { StopListenningForFilterValueChanges(); foreach (Pack pack in packs.Select(Database.GetPackById)) { if (pack == null) { Program.TraceWarning("Received pack is missing from the database. Pack is ignored."); continue; } Pack.PackContent content = pack.CrackOpen(); foreach (CardModel c in content.LimitedCards) { CardPool.Add(c); } foreach (CardModel c in content.UnlimitedCards) { UnlimitedPool.Add(c); } } UpdateFilters(); ListenForFilterValueChanges(); }
private void RemoveDeckCard(object sender, RoutedEventArgs e) { var src = e.OriginalSource as FrameworkElement; if (src == null) { return; } var element = (src.DataContext as ObservableMultiCard); if (element == null) { return; } var section = deckTabs.SelectedItem as ObservableSection; if (element.Quantity > 1) { OpenQuantityPopup(qty => { int actuallyRemoved = Math.Min(qty, element.Quantity); if (element.Quantity > qty) { element.Quantity -= (byte)qty; } else if (section != null) { section.Cards.RemoveCard(element); } if (!UnlimitedPool.Contains(element)) { for (int i = 0; i < actuallyRemoved; ++i) { // When there are multiple copies of the same card, we insert clones of the CardModel. // Otherwise, the ListBox gets confused with selection. CardPool.Add(element.Quantity > 1 ? element.AsObservable() : element); element.Quantity = 1; } } ; }); } else { if (element.Quantity > 1) { element.Quantity--; } else if (section != null) { section.Cards.RemoveCard(element); } if (!UnlimitedPool.Contains(element)) { CardPool.Add(element); } } }
public List <CardInfo> MakePick(int pickIndex) { var booster = Boosters.Dequeue(); CardPool.Add(booster[pickIndex]); booster.RemoveAt(pickIndex); return(booster); }
private void InitCardPool(string cdbFile, int mainNum, int exNum) { List <string> CardPoolLocal = new List <string>(); List <string> CardPoolExLocal = new List <string>(); SQLiteConnection sqlcon = new SQLiteConnection($"Data Source={cdbFile}"); sqlcon.Open(); SQLiteCommand cmd = new SQLiteCommand("SELECT id,type FROM datas", sqlcon); var reader = cmd.ExecuteReader(); while (reader.Read()) { string id = reader["id"].ToString(); long type = (long)reader["type"]; int num = 3; CardPoolLFList.Add(id, 0); if (LFList.ContainsKey(id)) { num = LFList[id]; } if (((type & TYPE_FUSION) > 0) || ((type & TYPE_XYZ) > 0) || ((type & TYPE_LINK) > 0) || ((type & TYPE_SYNCHRO) > 0)) { for (int i = 0; i < num; i++) { CardPoolExLocal.Add(id); } } else { for (int i = 0; i < num; i++) { CardPoolLocal.Add(id); } } } for (int i = 0; i < mainNum; i++) { int index = _rd.Next(0, CardPoolLocal.Count); CardPool.Add(CardPoolLocal[index]); CardPoolLocal.RemoveAt(index); if (!CardPoolLFList.ContainsKey(CardPoolLocal[index])) { CardPoolLFList.Add(CardPoolLocal[index], 1); } else { CardPoolLFList[CardPoolLocal[index]]++; } } for (int i = 0; i < exNum; i++) { int index = _rd.Next(0, CardPoolExLocal.Count); CardPoolEx.Add(CardPoolExLocal[index]); CardPoolLFList[CardPoolExLocal[index]]++; CardPoolExLocal.RemoveAt(index); } reader.Close(); cmd.Dispose(); sqlcon.Dispose(); CardPoolLocal.Clear(); CardPoolExLocal.Clear(); }