Beispiel #1
0
        private void GameEventManagerOnStartingNewGame(object sender, StartingNewGameEventArgs startingNewGameEventArgs)
        {
            _isStartingNewGame = true;
            Log.DebugFormat("GameEventManagerOnStartingNewGame");

            if (!_isUnlocking && _findNewQuest)
            {
                var foundQuest = false;
                var quests     = TritonHs.CurrentQuests;
                StatsSettings.Instance.Quests = TritonHs.CurrentQuests.Count;

                // Choose a basic deck to complete the quests.
                foreach (var quest in quests)
                {
                    // Loop through for each each class.
                    foreach (var @class in TritonHs.BasicHeroTagClasses)
                    {
                        // If this is a class specific quest, find a suitable deck. Otherwise,
                        // just use a random custom deck.
                        if (TritonHs.IsQuestForSpecificClass(quest.Id))
                        {
                            // If this quest is a win quest for this class.

                            if (TritonHs.IsQuestForClass(quest.Id, @class))
                            {
                                Log.InfoFormat(
                                    "[Quest] Now choosing the basic hero class to complete 要求职业的任务: [{0}] ,任务ID: [{1}] with.",
                                    quest.Name, quest.Id);

                                DefaultBotSettings.Instance.ConstructedDeckType  = DeckType.Basic;
                                DefaultBotSettings.Instance.ConstructedBasicDeck = @class;
                                unlockDeck = @class;
                                foundQuest = true;
                                break;
                            }
                        }
                    }

                    // If we found a quest and changed bot settings, we're done.
                    if (foundQuest)
                    {
                        break;
                    }

                    // Make sure we have a non-class quest to choose a random deck for.
                    if (!TritonHs.IsQuestForSpecificClass(quest.Id)) //不要求职业的任务
                    {
                        var decks = TritonHs.BasicHeroTagClasses;

                        // //Choose a random deck. We can add more logic for selection later...
                        var deck = decks[Client.Random.Next(0, decks.Length)];

                        Log.InfoFormat("[Quest] 预留功能,开发卡牌组,不要求职业的任务: [{0}] ,任务ID: [{1}]", quest.Name, quest.Id);

                        DefaultBotSettings.Instance.ConstructedDeckType  = DeckType.Basic;
                        DefaultBotSettings.Instance.ConstructedBasicDeck = deck;

                        foundQuest = true;
                        break;
                    }
                }
            }
        }
Beispiel #2
0
        private void GameEventManagerOnStartingNewGame(object sender, StartingNewGameEventArgs startingNewGameEventArgs)
        {
            var usableDecks = QuestSettings.Instance.UsableDecks;

            if (_findNewQuest)
            {
                var quests = TritonHs.CurrentQuests;

                // Remove Tavern Brawl quest and spectate.
                quests = quests.Where(q => q.Id != 222 && q.Id != 214).ToList();

                // No quests to do, not much else for this plugin to mess with.
                if (!quests.Any())
                {
                    // Stop the bot if the user wants it.
                    if (QuestSettings.Instance.StopAfterAllQuestsAreDone)
                    {
                        Log.ErrorFormat(
                            "[日常任务插件] Now stopping the bot, because there are no quests to complete and [StopAfterAllQuestsAreDone] is enabled.");
                        BotManager.Stop();
                        return;
                    }

                    _findNewQuest = false;

                    if (usableDecks.Any())
                    {
                        // Choose a random deck. We can add more logic for selection later...
                        var rngDeck =
                            usableDecks[
                                Client.Random.Next(0, usableDecks.Count)];

                        Log.InfoFormat("[Quest] Now choosing a random custom deck to play with since all quests are done.");

                        DefaultBotSettings.Instance.ConstructedCustomDeck = rngDeck.Name;
                        if (rngDeck.IsWild)
                        {
                            DefaultBotSettings.Instance.ConstructedGameRule = GameRule.狂野模式;
                        }
                        else
                        {
                            DefaultBotSettings.Instance.ConstructedGameRule = GameRule.标准模式;
                        }
                    }
                    return;
                }

                var foundQuest = false;

                // First, look for a quest to complete with a custom deck. We want to use custom decks to complete quests first,
                // before trying to use a basic deck (which is why this logic is two parts).
                foreach (var quest in quests)
                {
                    // Loop through for each each class.
                    foreach (var @class in TritonHs.BasicHeroTagClasses)
                    {
                        // If this is a class specific quest, find a suitable deck. Otherwise,
                        // just use a random custom deck.
                        if (TritonHs.IsQuestForSpecificClass(quest.Id))
                        {
                            // If this quest is a win quest for this class.
                            if (TritonHs.IsQuestForClass(quest.Id, @class))
                            {
                                // Check to see if we have a custom deck to complete it with.
                                var cardId = TritonHs.GetBasicHeroCardIdFromClass(@class);
                                var decks  =
                                    usableDecks.Where(d => d.HeroCardId == cardId).ToList();
                                if (decks.Any())
                                {
                                    // Choose a random deck. We can add more logic for selection later...
                                    var deck = decks[Client.Random.Next(0, decks.Count)];

                                    Log.InfoFormat(
                                        "[Quest] Now choosing a random compatible deck to complete the class specific quest [{0}] with.",
                                        quest.Name);

                                    DefaultBotSettings.Instance.ConstructedCustomDeck = deck.Name;
                                    if (deck.IsWild)
                                    {
                                        DefaultBotSettings.Instance.ConstructedGameRule = GameRule.狂野模式;
                                    }
                                    else
                                    {
                                        DefaultBotSettings.Instance.ConstructedGameRule = GameRule.标准模式;
                                    }

                                    foundQuest = true;

                                    break;
                                }
                            }
                        }
                    }

                    // If we found a quest and changed bot settings, we're done.
                    if (foundQuest)
                    {
                        break;
                    }

                    // Make sure we have a non-class quest to choose a random deck for.
                    // Also make sure we have custom decks in the first place.

                    var filterDecks = usableDecks;
                    if (quest.Id == 341 || quest.Id == 340)
                    {
                        filterDecks = filterDecks.Where(d => !d.IsWild).ToList();
                    }

                    if (!TritonHs.IsQuestForSpecificClass(quest.Id) && filterDecks.Any())
                    {
                        // Choose a random deck. We can add more logic for selection later...
                        var rngDeck = filterDecks[Client.Random.Next(0, filterDecks.Count)];

                        Log.InfoFormat(
                            "[Quest] Now choosing a random compatible deck to complete the non-class specific quest [{0}] with.",
                            quest.Name);

                        DefaultBotSettings.Instance.ConstructedCustomDeck = rngDeck.Name;
                        if (rngDeck.IsWild)
                        {
                            DefaultBotSettings.Instance.ConstructedGameRule = GameRule.狂野模式;
                        }
                        else
                        {
                            DefaultBotSettings.Instance.ConstructedGameRule = GameRule.标准模式;
                        }

                        foundQuest = true;

                        break;
                    }
                }

                // All done? For now, yes.
                if (foundQuest)
                {
                    _findNewQuest = false;
                    return;
                }

                Log.ErrorFormat(
                    "[日常任务插件] 现在停止挂机, 本卡组的任务已经完成.");
                BotManager.Stop();
            }
        }