コード例 #1
0
        public static bool AutoImportConstructed(bool select, bool brawl = false)
        {
            var decks = brawl ? DeckImporter.FromBrawl() : DeckImporter.FromConstructed();

            if (decks.Any() && (Config.Instance.ConstructedAutoImportNew || Config.Instance.ConstructedAutoUpdate))
            {
                ImportDecks(decks, brawl, Config.Instance.ConstructedAutoImportNew, Config.Instance.ConstructedAutoUpdate, select);
                return(true);
            }
            return(false);
        }
コード例 #2
0
        internal static async void AutoSelectDeckById(IGame game, long id)
        {
            Log.Info($"Trying to select deck for id={id}");
            if (id <= 0)
            {
                if (game.CurrentMode == Mode.ADVENTURE)
                {
                    while (game.IsDungeonMatch == null)
                    {
                        await Task.Delay(500);
                    }
                    if (game.IsDungeonMatch.Value)
                    {
                        return;
                    }
                }
                Log.Info("No selected deck found, using no-deck mode");
                Core.MainWindow.SelectDeck(null, true);
                return;
            }
            AutoImportConstructed(false, game.CurrentMode == Mode.TAVERN_BRAWL);
            var selectedDeck = DeckList.Instance.Decks.FirstOrDefault(x => x.HsId == id);

            if (selectedDeck == null)
            {
                Log.Warn($"No deck with id={id} found");
                return;
            }
            Log.Info("Found selected deck: " + selectedDeck.Name);
            var hsDeck          = DeckImporter.FromConstructed(false).FirstOrDefault(x => x.Deck.Id == id)?.Deck;
            var selectedVersion = selectedDeck.GetSelectedDeckVersion();

            if (hsDeck != null && !selectedVersion.Cards.All(c => hsDeck.Cards.Any(c2 => c.Id == c2.Id && c.Count == c2.Count)))
            {
                var nonSelectedVersions = selectedDeck.VersionsIncludingSelf.Where(v => v != selectedVersion.Version).Select(selectedDeck.GetVersion);
                var version             = nonSelectedVersions.FirstOrDefault(v => v.Cards.All(c => hsDeck.Cards.Any(c2 => c.Id == c2.Id && c.Count == c2.Count)));
                if (version != null)
                {
                    selectedDeck.SelectVersion(version);
                    Log.Info("Switching to version: " + version.Version.ShortVersionString);
                }
            }
            else if (Equals(selectedDeck, DeckList.Instance.ActiveDeck))
            {
                Log.Info("Already using the correct deck");
                return;
            }
            Core.MainWindow.SelectDeck(selectedDeck, true);
        }