Exemplo n.º 1
0
    private static CollectionFilterSet GetCardsIOwnFilterSet()
    {
        CollectionFilterSet set = new CollectionFilterSet(true);

        set.AddAccountFilter(ACCOUNT_TAG.OWNED_COUNT, 1, CollectionFilterFunc.GREATER_EQUAL);
        return(set);
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 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);
    }