Exemple #1
0
 public static List <string> GetCards(bool standardOnly) =>
 standardOnly?All.Where(x => !Helper.WildOnlySets.Contains(Database.GetCardFromId(x).Set)).ToList() : All;
Exemple #2
0
 public static Card GetCardFromId(string cardId)
 {
     return(Database.GetCardFromId(cardId));
 }
 public static Card GetCardFromId(string cardId) => Database.GetCardFromId(cardId);
Exemple #4
0
 private static int GetDbfId(string cardId) => Database.GetCardFromId(cardId)?.DbfIf ?? 0;
Exemple #5
0
        public async void NewArenaCard(string cardId)
        {
            if (TempArenaDeck == null || string.IsNullOrEmpty(cardId))
            {
                return;
            }
            var existingCard = TempArenaDeck.Cards.FirstOrDefault(c => c.Id == cardId);

            if (existingCard != null)
            {
                existingCard.Count++;
            }
            else
            {
                TempArenaDeck.Cards.Add((Card)Database.GetCardFromId(cardId).Clone());
            }
            var numCards = TempArenaDeck.Cards.Sum(c => c.Count);

            Logger.WriteLine(string.Format("Added new card to arena deck: {0} ({1}/30)", cardId, numCards));
            if (numCards == 30)
            {
                Logger.WriteLine("Found complete arena deck!");
                if (!Config.Instance.SelectedArenaImportingBehaviour.HasValue)
                {
                    Logger.WriteLine("...but we are using the old importing method.");
                    return;
                }
                var recentArenaDecks = DeckList.Instance.Decks.Where(d => d.IsArenaDeck).OrderByDescending(d => d.LastPlayedNewFirst).Take(15);
                if (recentArenaDecks.Any(d => d.Cards.All(c => TempArenaDeck.Cards.Any(c2 => c.Id == c2.Id && c.Count == c2.Count))))
                {
                    Logger.WriteLine("...but we already have that one. Discarding.");
                    TempArenaDeck = null;
                    return;
                }
                if (DiscardedArenaDecks.Any(d => d.Cards.All(c => TempArenaDeck.Cards.Any(c2 => c.Id == c2.Id && c.Count == c2.Count))))
                {
                    Logger.WriteLine("...but it was already discarded by the user. No automatic action taken.");
                    return;
                }
                if (Config.Instance.SelectedArenaImportingBehaviour.Value == ArenaImportingBehaviour.AutoImportSave)
                {
                    Logger.WriteLine("...auto saving new arena deck.");
                    Helper.MainWindow.SetNewDeck(TempArenaDeck);
                    Helper.MainWindow.SaveDeck(false, TempArenaDeck.Version);
                    TempArenaDeck = null;
                }
                else if (Config.Instance.SelectedArenaImportingBehaviour.Value == ArenaImportingBehaviour.AutoAsk)
                {
                    var result =
                        await
                        Helper.MainWindow.ShowMessageAsync("New arena deck detected!",
                                                           "You can change this behaviour to \"auto save&import\" or \"manual\" in [options > tracker > importing]",
                                                           MessageDialogStyle.AffirmativeAndNegative,
                                                           new MetroDialogSettings { AffirmativeButtonText = "import", NegativeButtonText = "cancel" });

                    if (result == MessageDialogResult.Affirmative)
                    {
                        Logger.WriteLine("...saving new arena deck.");
                        Helper.MainWindow.SetNewDeck(TempArenaDeck);
                        Helper.MainWindow.ActivateWindow();
                        TempArenaDeck = null;
                    }
                    else
                    {
                        Logger.WriteLine("...discarded by user.");
                        DiscardedArenaDecks.Add(TempArenaDeck);
                        TempArenaDeck = null;
                    }
                }
            }
        }