예제 #1
0
        private static IReadOnlyList <int> BuildRealDeckList(HearthstoneImage image, IDungeonInfo runFromMemory)
        {
            var deckList = new List <int>();

            // The current run is in progress, which means the value held in the DeckCards
            // field is the aggregation of the cards picked in the previous steps
            // TODO: how to handle card changed / removed by Bob?
            if (runFromMemory.RunActive == 1)
            {
                deckList = runFromMemory.DeckCards.ToList();
                if (runFromMemory.ChosenLoot > 0)
                {
                    // index is 1-based
                    var chosenBundle = runFromMemory.LootOptionBundles[runFromMemory.ChosenLoot - 1];

                    // First card is the name of the bundle
                    for (var i = 1; i < chosenBundle.Count; i++)
                    {
                        deckList.Add(chosenBundle[i]);
                    }
                }

                if (runFromMemory.ChosenTreasure > 0)
                {
                    deckList.Add(runFromMemory.TreasureOption[runFromMemory.ChosenTreasure - 1]);
                }
            }
            else
            {
                if (runFromMemory.SelectedDeck > 0)
                {
                    deckList.Add(runFromMemory.StartingTreasure);

                    var dbf          = image["GameDbf"];
                    var starterDecks = dbf["Deck"]["m_records"]["_items"];
                    for (var i = 0; i < starterDecks.Length; i++)
                    {
                        var deckId = starterDecks[i]["m_ID"];
                        if (deckId == runFromMemory.SelectedDeck)
                        {
                            var topCardId = starterDecks[i]["m_topCardId"];
                            var cardDbf   = DungeonInfoReader.GetDeckCardDbf(image, topCardId);
                            while (cardDbf != null)
                            {
                                deckList.Add(cardDbf["m_cardId"]);
                                var next = cardDbf["m_nextCardId"];
                                cardDbf = next == 0 ? null : DungeonInfoReader.GetDeckCardDbf(image, next);
                            }
                        }
                    }
                }
            }

            // Some cards can be set to 0, when they are removed by Bob for instance
            return(deckList.Where(id => id > 0).ToArray());
        }
        private static List <int> BuildRealDeckListForNewRun(HearthstoneImage image, IDungeonInfo runFromMemory)
        {
            var deckList   = new List <int>();
            var isValidRun = runFromMemory.SelectedDeck > 0 && IsValidRun(image);

            if (isValidRun)
            {
                deckList.Add(runFromMemory.StartingTreasure);
                deckList.AddRange(ActiveDeckReader.GetTemplateDeck(image, runFromMemory.SelectedDeck));
            }
            return(deckList);
        }
        private static IReadOnlyList <int> BuildRealDeckList(HearthstoneImage image, IDungeonInfo runFromMemory)
        {
            // The current run is in progress, which means the value held in the DeckCards
            // field is the aggregation of the cards picked in the previous steps
            // TODO: how to handle card changed / removed by Bob?
            var deckList = runFromMemory.RunActive == 1
                ? BuildRealDeckListForActiveRun(runFromMemory)
                : BuildRealDeckListForNewRun(image, runFromMemory);

            // Some cards can be set to 0, when they are removed by Bob for instance
            return(deckList.Where(id => id > 0).ToArray());
        }
        private static List <int> BuildRealDeckListForActiveRun(IDungeonInfo runFromMemory)
        {
            var deckList = runFromMemory.DeckCards.ToList();

            if (runFromMemory.ChosenLoot > 0)
            {
                // index is 1-based
                var chosenBundle = runFromMemory.LootOptionBundles[runFromMemory.ChosenLoot - 1];

                // First card is the name of the bundle
                for (var i = 0; i < chosenBundle.Elements.Count; i++)
                {
                    deckList.Add(chosenBundle.Elements[i]);
                }
            }

            if (runFromMemory.ChosenTreasure > 0)
            {
                deckList.Add(runFromMemory.TreasureOption[runFromMemory.ChosenTreasure - 1]);
            }
            return(deckList);
        }
 public bool TryGetValue(DungeonKey key, out IDungeonInfo value) =>
 this.internalDictionary.TryGetValue(key, out value);