예제 #1
0
    public static RDM_Deck FinishMyDeck(RDM_Deck currentDeck)
    {
        Log.Ben.Print("Finishing the Current Deck.", new object[0]);
        int num = 30 - currentDeck.deckList.Count;

        if (num > 0)
        {
            for (int i = 0; i < num; i++)
            {
                RandomDeckChoices choices = GetChoices(currentDeck, 1);
                if (choices.choices.Count <= 0)
                {
                    Debug.LogError("Tried to Finish this deck, but Brode's algorithm broke and couldn't do it.");
                    return(currentDeck);
                }
                RDMDeckEntry entry = choices.choices[0];
                Log.Ben.Print(string.Format("{0} - {1} (flair {2})", choices.displayString, entry.EntityDef.GetDebugName(), entry.Flair), new object[0]);
                currentDeck.deckList.Add(choices.choices[0]);
            }
        }
        return(currentDeck);
    }
 public void UpdateChoices()
 {
     this.CleanOldChoices();
     if (this.IsActive())
     {
         RandomDeckChoices choices = RandomDeckMaker.GetChoices(CollectionManagerDisplay.Get().GetRDMDeck(), 3);
         if (choices == null)
         {
             UnityEngine.Debug.LogError("DeckHelper.GetChoices() - Can't find choices!!!!");
         }
         else
         {
             foreach (RDMDeckEntry entry in choices.choices)
             {
                 this.m_cardIdChoices.Add(entry.EntityDef.GetCardId());
             }
             bool flag = !this.m_instructionText.Text.Equals(choices.displayString);
             this.m_instructionText.Text = choices.displayString;
             if ((UniversalInputManager.UsePhoneUI != null) && flag)
             {
                 if (NotificationManager.Get().IsQuotePlaying)
                 {
                     this.m_instructionText.Text = string.Empty;
                 }
                 else
                 {
                     this.ShowInnkeeperPopup();
                 }
             }
             foreach (RDMDeckEntry entry2 in choices.choices)
             {
                 Log.Ben.Print(entry2.EntityDef.GetDebugName(), new object[0]);
                 CollectionCardCache.Get().LoadCardDef(entry2.EntityDef.GetCardId(), new CollectionCardCache.LoadCardDefCallback(this.OnCardDefLoaded), entry2, new CardPortraitQuality(3, entry2.Flair.Premium));
             }
         }
     }
 }
예제 #3
0
    public static RandomDeckChoices GetChoices(RDM_Deck currentDeck, int numChoicesRequired)
    {
        if (currentDeck.deckList.Count >= 30)
        {
            Debug.LogWarning("RandomDeckMaker.GetChoices(): Tried to get choices for a full deck!");
            return(null);
        }
        int num = 0;

        foreach (RDMDeckEntry entry in currentDeck.deckList)
        {
            if (entry.EntityDef.GetClass() == currentDeck.classType)
            {
                num++;
            }
        }
        CollectionFilterSet cardsIOwnFilterSet = GetCardsIOwnFilterSet();
        RandomDeckChoices   returnChoices      = new RandomDeckChoices();

        returnChoices.Clear();
        if (num < 12)
        {
            cardsIOwnFilterSet.RemoveAllGameFilters();
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.CLASS, currentDeck.classType, CollectionFilterFunc.EQUAL);
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.CARDTYPE, TAG_CARDTYPE.HERO, CollectionFilterFunc.NOT_EQUAL);
            List <FilteredArtStack> newChoiceOptions = cardsIOwnFilterSet.GenerateList();
            returnChoices.displayString = GameStrings.Get(GAME_STRING_CLASS_SPECIFIC);
            for (int k = 0; k < numChoicesRequired; k++)
            {
                RDMDeckEntry item = GetValidChoiceForDeck(newChoiceOptions, returnChoices.choices, currentDeck);
                if (item != null)
                {
                    returnChoices.choices.Add(item);
                }
            }
            if (returnChoices.choices.Count == numChoicesRequired)
            {
                return(returnChoices);
            }
        }
        returnChoices.Clear();
        Map <int, List <RDMDeckEntry> > deckCardsByManaCost = new Map <int, List <RDMDeckEntry> >();

        foreach (RDMDeckEntry entry3 in currentDeck.deckList)
        {
            int key = Mathf.Clamp(entry3.EntityDef.GetCost(), 1, 7);
            if (!deckCardsByManaCost.ContainsKey(key))
            {
                deckCardsByManaCost.Add(key, new List <RDMDeckEntry>());
            }
            deckCardsByManaCost[key].Add(entry3);
        }
        for (int i = 0; i < COST_REQUIREMENTS.Length; i++)
        {
            if (GetChoicesByCost(COST_REQUIREMENTS[i], numChoicesRequired, currentDeck, deckCardsByManaCost, ref returnChoices))
            {
                return(returnChoices);
            }
        }
        int num5 = 0;
        int num6 = 0;

        foreach (RDMDeckEntry entry4 in currentDeck.deckList)
        {
            if (entry4.EntityDef.IsSpell())
            {
                num5++;
            }
            if (entry4.EntityDef.IsMinion())
            {
                num6++;
            }
        }
        returnChoices.Clear();
        if (num5 < 8)
        {
            cardsIOwnFilterSet.RemoveAllGameFilters();
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.CARDTYPE, TAG_CARDTYPE.SPELL, CollectionFilterFunc.EQUAL);
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.CARDTYPE, TAG_CARDTYPE.HERO, CollectionFilterFunc.NOT_EQUAL);
            List <FilteredArtStack> list2 = cardsIOwnFilterSet.GenerateList();
            returnChoices.displayString = GameStrings.Get(GAME_STRING_MORE_SPELLS);
            for (int m = 0; m < numChoicesRequired; m++)
            {
                RDMDeckEntry entry5 = GetValidChoiceForDeck(list2, returnChoices.choices, currentDeck);
                if (entry5 != null)
                {
                    returnChoices.choices.Add(entry5);
                }
            }
            if (returnChoices.choices.Count == numChoicesRequired)
            {
                return(returnChoices);
            }
        }
        returnChoices.Clear();
        if (num6 < 15)
        {
            cardsIOwnFilterSet.RemoveAllGameFilters();
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.CARDTYPE, TAG_CARDTYPE.MINION, CollectionFilterFunc.EQUAL);
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.CARDTYPE, TAG_CARDTYPE.HERO, CollectionFilterFunc.NOT_EQUAL);
            List <FilteredArtStack> list3 = cardsIOwnFilterSet.GenerateList();
            returnChoices.displayString = GameStrings.Get(GAME_STRING_MORE_MINIONS);
            for (int n = 0; n < numChoicesRequired; n++)
            {
                RDMDeckEntry entry6 = GetValidChoiceForDeck(list3, returnChoices.choices, currentDeck);
                if (entry6 != null)
                {
                    returnChoices.choices.Add(entry6);
                }
            }
            if (returnChoices.choices.Count == numChoicesRequired)
            {
                return(returnChoices);
            }
        }
        returnChoices.Clear();
        returnChoices.displayString = GameStrings.Get(GAME_STRING_NO_SPECIFICS);
        for (int j = 0; j < numChoicesRequired; j++)
        {
            cardsIOwnFilterSet.RemoveAllGameFilters();
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.CARDTYPE, TAG_CARDTYPE.HERO, CollectionFilterFunc.NOT_EQUAL);
            RDMDeckEntry entry7 = GetValidChoiceForDeck(cardsIOwnFilterSet.GenerateList(), returnChoices.choices, currentDeck);
            if (entry7 != null)
            {
                returnChoices.choices.Add(entry7);
            }
        }
        return(returnChoices);
    }
예제 #4
0
    private static bool GetChoicesByCost(CostRequirement costRequirement, int numChoicesRequired, RDM_Deck currentDeck, Map <int, List <RDMDeckEntry> > deckCardsByManaCost, ref RandomDeckChoices returnChoices)
    {
        int costFilterValue      = costRequirement.m_costFilterValue;
        List <RDMDeckEntry> list = !deckCardsByManaCost.ContainsKey(costFilterValue) ? null : deckCardsByManaCost[costFilterValue];
        int num2 = (list != null) ? list.Count : 0;

        if (num2 < costRequirement.m_minNumCards)
        {
            returnChoices.Clear();
            returnChoices.displayString = GameStrings.Get(costRequirement.m_displayStringKey);
            CollectionFilterSet cardsIOwnFilterSet = GetCardsIOwnFilterSet();
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.COST, costFilterValue, costRequirement.m_costFilterFunc);
            cardsIOwnFilterSet.AddGameFilter(GAME_TAG.CARDTYPE, TAG_CARDTYPE.HERO, CollectionFilterFunc.NOT_EQUAL);
            List <FilteredArtStack> newChoiceOptions = cardsIOwnFilterSet.GenerateList();
            for (int i = 0; i < numChoicesRequired; i++)
            {
                RDMDeckEntry item = GetValidChoiceForDeck(newChoiceOptions, returnChoices.choices, currentDeck);
                if (item != null)
                {
                    returnChoices.choices.Add(item);
                }
            }
            if (returnChoices.choices.Count >= numChoicesRequired)
            {
                return(true);
            }
            returnChoices.Clear();
        }
        return(false);
    }