Example #1
0
    public bool Draw(CardListFilter filter, int?numToChoose = null)
    {
        var drawnCard = Deck.Draw(filter, out bool failedFilter, numToChoose);

        if (!failedFilter)
        {
            if (numToChoose == null)
            {
                if (drawnCard != null)
                {
                    AddToHand(drawnCard);
                }
                else
                {
                    Debug.Log("Deck is empty");
                }
            }

            return(true);
        }
        else
        {
            Debug.Log("Given filter cannot draw any cards from the deck");
            return(false);
        }
    }
Example #2
0
    public List <Card> Draw(int numToDraw, CardListFilter filter, out int failedDraws, out bool failedFilter)
    {
        var drawnCards = new List <Card>();

        failedDraws  = numToDraw;
        failedFilter = false;

        for (int count = 0; count < numToDraw; count++)
        {
            int currentCount = ListCount;

            if (currentCount != 0)
            {
                var filteredDeck = FilterCardList(filter);

                if (filteredDeck.cardList.Count != 0)
                {
                    drawnCards.Add(filteredDeck.cardList.LastOrDefault());
                    cardList.Remove(drawnCards.LastOrDefault());
                    failedDraws--;
                }
                else
                {
                    failedFilter = true;
                    break;
                }
            }
            else
            {
                break;
            }
        }

        return(drawnCards);
    }
Example #3
0
    public void Draw(int numToDraw, CardListFilter filter)
    {
        var drawnCards = Deck.Draw(numToDraw, filter, out int failedDraws, out bool failedFilter);

        if (!failedFilter)
        {
            if (drawnCards.Count != 0)
            {
                foreach (var drawnCard in drawnCards)
                {
                    AddToHand(drawnCard);
                }

                if (failedDraws > 0)
                {
                    Debug.Log($"Failed to draw {failedDraws} from the deck as there were not enough cards remaining");
                }
            }
            else
            {
                Debug.Log("Deck is empty");
            }
        }
        else
        {
            Debug.Log("Given filter cannot draw any cards from the deck");
        }
    }
Example #4
0
        //A játékos választ egy előre definiált paraméterekkel rendelkező kártyalistából
        public void MakePlayerChooseCard(CardListFilter filter = CardListFilter.None, int limit = 0)
        {
            int currentKey = modules.GetGameModule().GetCurrentKey();

            //Megjelenítjük a kézben lévő lapokat, hogy a játékos választhasson közülük
            ChooseCard(currentKey, filter, limit);
        }
Example #5
0
    public bool ReturnFromGraveyard(CardListFilter filter, int numToCreate, bool isDeploy, bool isRedeploy, bool isCopy, string createdBy, bool isChoice)
    {
        var filteredCardList = Graveyard.FilterCardList(filter);

        if (filteredCardList.ListCount == 0)
        {
            return(false);
        }

        var cardList = filteredCardList.GetRandomCards(numToCreate);

        if (!isChoice)
        {
            if (isDeploy)
            {
                var unitList = cardList.Cast <Unit>().ToList();
                if (isRedeploy)
                {
                    AddToRedeploy(unitList);
                }
                else
                {
                    GameManager.instance.effectManager.SetDeployUnits(unitList);
                }
            }
            else
            {
                if (isCopy)
                {
                    cardList = cardList.Select(x => GameManager.instance.libraryManager.CreateCard(x.CardData, this)).ToList();
                    cardList.ForEach(x => x.CreatedByName = createdBy);
                }

                foreach (var card in cardList)
                {
                    AddToHand(card);
                }
            }


            if (!isCopy)
            {
                Graveyard.RemoveCard(cardList);
            }
        }
        else
        {
            if (isDeploy)
            {
                GameManager.instance.effectManager.SetGraveyardToDeployChoiceMode(cardList);
            }
            else
            {
                GameManager.instance.effectManager.SetGraveyardToHandChoiceMode(cardList, isCopy, createdBy);
            }
        }

        return(true);
    }
Example #6
0
 //A megadott paraméterekkel megjelenít egy kártya listát, amiből választhat a játékos
 private void ChooseCard(int currentKey, CardListFilter filter, int limit)
 {
     //Ha ember
     if (modules.GetGameModule().IsTheActivePlayerHuman())
     {
         modules.GetGameModule().StartCoroutine(modules.GetClientModule().DisplayCardList(currentKey, filter, limit));
     }
 }
Example #7
0
    /// <summary>
    ///
    /// Function call from tutor draw area to confirm tutor draw
    ///
    /// </summary>
    public bool TutorDraw(CardListFilter cardFilter, int?numToChoose = null)
    {
        var filterSuccess = Player.Draw(cardFilter, numToChoose);

        if (filterSuccess)
        {
            PlayerUIBar.RefreshPlayerBar();
        }
        return(filterSuccess);
    }
    public void ConfirmButton()
    {
        if (isDeployToggle.isOn || !isCopyToggle.isOn || isCopyToggle.isOn && !string.IsNullOrWhiteSpace(createdByInput.text))
        {
            var player = GameManager.instance.GetPlayer(activeOwnerToggle.isOn);

            var filter = new CardListFilter()
            {
                Name = nameInput.text,
            };

            if (tagDropdown.captionText.text != DEFAULT_DROPDOWN_STRING)
            {
                filter.Tag = (Tags)Enum.Parse(typeof(Tags), tagDropdown.captionText.text.Replace(" ", ""));
            }
            if (typeDropdown.captionText.text != DEFAULT_DROPDOWN_STRING)
            {
                filter.CardType = (CardTypes)Enum.Parse(typeof(CardTypes), typeDropdown.captionText.text.Replace(" ", ""));
            }

            int numberToCreate = 1;
            if (int.TryParse(numToCreateInput.text, out int result) && numToCreateInput.text != "0")
            {
                numberToCreate = Mathf.Max(1, result);
            }

            if (player.ReturnFromGraveyard(filter, numberToCreate, isDeployToggle.isOn, isRedeployToggle.isOn, isCopyToggle.isOn, createdByInput.text, isChoiceToggle.isOn))
            {
                if (isDeployToggle.isOn && !isRedeployToggle.isOn)
                {
                    StartEffect();
                }

                if (!isChoiceToggle.isOn)
                {
                    GameManager.instance.uiManager.RefreshUI();
                }
            }
            else
            {
                titleText.text = $"{defaultTitleText} (Failed)";
            }
        }
        else
        {
            createdByInput.placeholder.color = new Color(0.8f, 0.0f, 0.0f, 0.5f);
            titleText.text = $"{defaultTitleText} (Input Created By)";
        }

        if (isRedeployToggle.isOn)
        {
            gameObject.SetActive(false);
        }
    }
Example #9
0
    /// <summary>
    ///
    /// Initialises the tutor draw area when it is opened
    ///
    /// </summary>
    public void OpenTutorDrawArea()
    {
        TutorDrawFilter = new CardListFilter();

        titleText.text = "Tutor Draw";

        //Sets area to default values
        dropdownFields.ForEach(x => x.value = 0);
        inputFields.ForEach(x => x.text     = "");
        isCreatedToggle.isOn         = false;
        isCreatedToggle.interactable = false;
        isChoiceToggle.isOn          = false;
        IsChoiceToggleChange();

        OnCardTypeChange();
    }
Example #10
0
        private List <Card> GetFilteredList(List <Card> cardlist, int playerKey, CardListFilter filter)
        {
            //Ha nem jeleníthetünk meg Master Crockot
            if (filter == CardListFilter.NoMasterCrok)
            {
                cardlist.RemoveAll(card => card.GetCardType() == CardType.Master_Crok);
            }

            //Ha nincs különösebb kitétel arra, hogy milyen lapokat adjunk vissza
            else if (filter == CardListFilter.EnemyDoppelganger)
            {
                List <int> opponentsID = GetOtherCardsID(playerKey);
                cardlist.RemoveAll(card => !(opponentsID.Contains(card.GetCardID())));
            }

            return(cardlist);
        }
Example #11
0
        public List <Card> GetCardsFromPlayer(int playerKey, CardListTarget target, CardListFilter filter = CardListFilter.None, int limit = 0)
        {
            List <Card> cardList   = new List <Card>();
            List <Card> resultList = new List <Card>();

            switch (target)
            {
            case CardListTarget.Hand:
                cardList = GetPlayerWithKey(playerKey).GetCardsInHand();
                break;

            case CardListTarget.Field:
                cardList = GetPlayerWithKey(playerKey).GetCardsOnField();
                break;

            case CardListTarget.Losers:
                cardList = GetPlayerWithKey(playerKey).GetLosers();
                break;

            case CardListTarget.Deck:
                cardList = GetPlayerWithKey(playerKey).GetDeck(limit);
                break;

            case CardListTarget.Winners:
                cardList = GetPlayerWithKey(playerKey).GetWinners();
                break;

            default:
                return(null);
            }


            foreach (Card card in cardList)
            {
                resultList.Add(card);
            }

            if (filter != CardListFilter.None)
            {
                resultList = GetFilteredList(resultList, playerKey, filter);
            }

            return(resultList);
        }
Example #12
0
    public Card Draw(CardListFilter filter, out bool failedFilter, int?numToChoose = null)
    {
        int currentCount = ListCount;

        failedFilter = false;

        if (currentCount != 0)
        {
            var filteredDeck = FilterCardList(filter);

            if (filteredDeck.cardList.Count != 0)
            {
                if (numToChoose == null)
                {
                    var drawnCard = filteredDeck.cardList.LastOrDefault();
                    cardList.Remove(drawnCard);

                    return(drawnCard);
                }
                else
                {
                    if (numToChoose.Value > filteredDeck.ListCount)
                    {
                        numToChoose = filteredDeck.ListCount;
                    }

                    var cardChoiceList = new List <Card>();
                    var completedList  = false;
                    for (int choiceIndex = 0; choiceIndex < numToChoose; choiceIndex++)
                    {
                        for (int cardIndex = 0; cardIndex < filteredDeck.ListCount; cardIndex++)
                        {
                            var card = filteredDeck.cardList[filteredDeck.ListCount - 1 - cardIndex];
                            if (cardChoiceList.Select(x => x.Name).Contains(card.Name))
                            {
                                if (cardIndex == filteredDeck.ListCount - 1)
                                {
                                    completedList = true;
                                    break;
                                }
                                continue;
                            }
                            cardChoiceList.Add(card);
                            break;
                        }

                        if (completedList)
                        {
                            break;
                        }
                    }

                    GameManager.instance.effectManager.SetDrawChoiceMode(cardChoiceList);

                    return(null);
                }
            }
            else
            {
                failedFilter = true;
                return(null);
            }
        }
        else
        {
            return(null);
        }
    }
        //Bizonyos kártya listát jelenít meg az aktív játékos számára, amiből választhat ezután
        public IEnumerator DisplayCardList(int currentKey, CardListFilter filter = CardListFilter.None, int limit = 0)
        {
            List <Card> cardList = new List <Card>();

            switch (modules.GetGameModule().GetCurrentListType())
            {
            case CardListTarget.Hand: cardList = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Hand, filter, limit); break;

            case CardListTarget.Winners: cardList = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Winners, filter, limit); break;

            case CardListTarget.Losers: cardList = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Losers, filter, limit); break;

            case CardListTarget.Deck: cardList = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Deck, filter, limit); break;

            case CardListTarget.Field: cardList = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Field, filter, limit); break;

            default: break;
            }
            SkillEffectAction currentAction = modules.GetGameModule().GetCurrentAction();

            string msg = "";

            switch (currentAction)
            {
            case SkillEffectAction.Switch:
                msg = "Válaszd ki, hogy melyik lappal cserélsz!";
                break;

            case SkillEffectAction.Revive:
                msg = "Válaszd ki, hogy melyik lapot éleszted fel!";
                break;

            case SkillEffectAction.SwitchOpponentCard:
                msg = "Válaszd ki, hogy melyik ellenséges lapot cseréled ki!";
                break;

            case SkillEffectAction.SacrificeFromHand:
                msg = "Válaszd ki, hogy melyik lapot áldozod fel az Erőért!";
                break;

            case SkillEffectAction.Reorganize:
                msg = "Változtasd meg a sorrendjét a kártyáidnak!";
                break;

            case SkillEffectAction.TossCard:
                msg = "Válaszd ki, hogy melyik lapot dobod el!";
                break;

            default:
                break;
            }

            //Ha van miből választani, akkor megjelenítjük a listát
            if (cardList.Count > 0)
            {
                CardChoice(cardList, currentAction, currentKey, msg);

                //Várunk a visszajelzésére
                yield return(modules.GetGameModule().WaitForEndOfAction());
            }

            else
            {
                if (currentAction == SkillEffectAction.SacrificeDoppelganger)
                {
                    modules.GetGameModule().StartCoroutine(DisplayNotification("Nincs megfelelő lap a kezedben!"));
                }

                modules.GetGameModule().SetSelectionAction(SkillEffectAction.None);
                modules.GetGameModule().SetSwitchType(CardListTarget.None);
                modules.GetGameModule().SkillFinished();
            }
        }
Example #14
0
    /// <summary>
    ///
    /// Apply the filter for a dropdown of a particular type
    ///
    /// </summary>
    private CardListFilter ApplyDropdownFilter <T>(TMP_Dropdown dropdown, CardListFilter activeFilter, CardListFilter.IntFilterTypes intFilterType = CardListFilter.IntFilterTypes.None)
    {
        //If the text is All, do not need to apply the filter
        if (dropdown.captionText.text != DEFAULT_DROPDOWN_STRING)
        {
            //Parses the selected value into the enum
            var selectedField = (T)Enum.Parse(typeof(T), dropdown.captionText.text.Replace(" ", ""));
            var type          = typeof(T);

            //Sets the filter to include the selected option based on the type of dropdown
            switch (type)
            {
            case Type _ when type == typeof(Rarity):
                activeFilter.Rarity = (Rarity)(object)selectedField;
                break;

            case Type _ when type == typeof(Classes.ClassList):
                activeFilter.Class = (Classes.ClassList)(object) selectedField;
                break;

            case Type _ when type == typeof(Tags):
                activeFilter.Tag = (Tags)(object)selectedField;
                break;

            case Type _ when type == typeof(CardResources):
                activeFilter.Resource = (CardResources)(object)selectedField;
                break;

            case Type _ when type == typeof(CardTypes):
                activeFilter.CardType = (CardTypes)(object)selectedField;
                break;

            case Type _ when type == typeof(IntValueFilter):
                var intValueFilter = (IntValueFilter)(object)selectedField;

                string inputText;

                //Determines which type of filter type is required to check and stores the text
                switch (intFilterType)
                {
                case CardListFilter.IntFilterTypes.Cost:
                    inputText = costInput.text;
                    break;

                case CardListFilter.IntFilterTypes.Attack:
                    inputText = attackInput.text;
                    break;

                case CardListFilter.IntFilterTypes.Health:
                    inputText = healthInput.text;
                    break;

                case CardListFilter.IntFilterTypes.Range:
                    inputText = rangeInput.text;
                    break;

                case CardListFilter.IntFilterTypes.Speed:
                    inputText = speedInput.text;
                    break;

                case CardListFilter.IntFilterTypes.SpellRange:
                    inputText = spellRangeInput.text;
                    break;

                case CardListFilter.IntFilterTypes.Durability:
                    inputText = durabilityInput.text;
                    break;

                default:
                    throw new Exception("Not a valid int filter type");
                }

                int?result;

                //Tries to parse the text result to an int
                if (int.TryParse(inputText, out int parseResult))
                {
                    //Clamps the result to keep it positive
                    result = Mathf.Max(0, parseResult);
                }
                else
                {
                    //If not a valid input, converts it to 0
                    result = 0;
                }

                //Adds the int filter to the filter
                activeFilter.AddIntFilter(intFilterType, intValueFilter, result);

                break;
            }
        }

        return(activeFilter);
    }
        //Kártyacsere vagy választás
        public IEnumerator CardSelectionEffect(int key, CardListFilter filter, int limit = 0, int otherPlayer = -1)
        {
            GetCurrentContext(key);

            //Ha cseréről van szó
            if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.Switch)
            {
                int handID = -1;

                //Ha kézből cserélünk
                if (modules.GetGameModule().GetCurrentListType() == CardListTarget.Hand)
                {
                    handID = Bot_Behaviour.HandSwitch(
                        modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Hand),
                        modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Field),
                        modules.GetDataModule().GetOpponentsCard(currentKey),
                        currentStat);

                    modules.GetSkillModule().SwitchCard(currentKey, modules.GetGameModule().GetActiveCardID(), handID);
                }
            }

            //Ha skill lopásról van szó
            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.SkillUse)
            {
                //Adatgyűjtés
                Card ownCard = modules.GetDataModule().GetCardFromPlayer(currentKey, modules.GetGameModule().GetActiveCardID(), CardListTarget.Field);
                List <PlayerCardPairs> cards = modules.GetDataModule().GetOtherLosers(currentKey);
                int index = Bot_Behaviour.WhichSkillToUse(cards);

                modules.GetInputModule().HandleCardSelection(cards[index].cardPosition, cards[index].playerKey);
                yield break;
            }

            //Ha felélesztésről van szó
            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.Revive)
            {
                List <Card> cards  = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Losers);
                int         cardID = Bot_Behaviour.WhomToRevive(cards);
                modules.GetInputModule().HandleCardSelection(cardID, currentKey);
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.Execute)
            {
                List <int> temp       = modules.GetDataModule().GetOtherKeyList(currentKey);
                int        choosenKey = Bot_Behaviour.WhichPlayerToExecute(temp);

                modules.GetInputModule().ReportNameBoxTapping(choosenKey);
                yield return(modules.GetGameModule().WaitForEndOfAction());
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.SwitchOpponentCard)
            {
                List <int> temp       = modules.GetDataModule().GetOtherKeyList(currentKey);
                int        choosenKey = Bot_Behaviour.WhichPlayerToExecute(temp);

                modules.GetInputModule().ReportNameBoxTapping(choosenKey);
                yield return(modules.GetGameModule().WaitForEndOfAction());
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.PickCardForSwitch)
            {
                List <Card> cardsOnField  = modules.GetDataModule().GetCardsFromPlayer(otherPlayer, CardListTarget.Field);
                int         choosenCardID = Bot_Behaviour.WhichCardToSwitch(cardsOnField);
                int         deckCount     = (modules.GetDataModule().GetDeckAmount(otherPlayer)) - 1;
                modules.GetGameModule().SetSwitchType(CardListTarget.Deck);
                modules.GetSkillModule().SwitchCard(otherPlayer, choosenCardID, deckCount);
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.CheckWinnerAmount)
            {
                List <int> keyList    = modules.GetDataModule().GetOtherKeyList(currentKey);
                List <int> winAmounts = modules.GetDataModule().GetOthersWinAmount(currentKey);

                int playerID = Bot_Behaviour.WhichPlayerToChoose(winAmounts);

                modules.GetInputModule().ReportNameBoxTapping(keyList[playerID]);
            }

            //Ha kézből eldobásról van szó
            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.TossCard)
            {
                //Csak akkor dobunk el lapot, ha van a kezünkben
                if (cardsInHand.Count > 1)
                {
                    int cardID = Bot_Behaviour.WhomToToss(cardsInHand);
                    modules.GetInputModule().HandleCardSelection(cardID, currentKey);
                }

                else
                {
                    Debug.Log("Nincs mit eldobni");
                    modules.GetGameModule().ActionFinished();
                }
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.SacrificeFromHand)
            {
                int cardID = Bot_Behaviour.WhomToToss(cardsInHand);
                modules.GetInputModule().HandleCardSelection(cardID, currentKey);
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.SacrificeDoppelganger)
            {
                List <Card> cardList = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Hand, filter);
                if (cardList.Count > 0)
                {
                    int cardID = Bot_Behaviour.WhomToToss(cardList);
                    modules.GetInputModule().HandleCardSelection(cardID, currentKey);
                }

                else
                {
                    Debug.Log("Nincs megfelelő lap a kézben");
                    modules.GetGameModule().ActionFinished();
                }
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.Reorganize)
            {
                List <Card> cardsInDeck = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Deck, CardListFilter.None, limit);
                cardsInDeck = Bot_Behaviour.OrganiseCardsInDeck(cardsInDeck, modules.GetDataModule().GetRNG());
                modules.GetInputModule().HandleChangeOfCardOrder(cardsInDeck, currentKey);
            }
        }
Example #16
0
    /// <summary>
    ///
    /// Filters a card list using a given filter object
    ///
    /// </summary>
    public CardList FilterCardList(CardListFilter filter)
    {
        var filteredCardList = new List <Card>();

        //Dictionary used to track either the highest or lowest value of each int value filter
        var intValueTracker = new Dictionary <CardListFilter.IntFilterTypes, int?>();

        //Loop through each card in the list. If fails a filter, continues through the loop
        foreach (var card in cardList)
        {
            if (filter.Name.Length > 0)
            {
                if (!filter.Name.ToLower().Contains(card.Name.ToLower()))
                {
                    continue;
                }
            }

            if (filter.Rarity != Rarity.Default)
            {
                if (filter.Rarity != card.Rarity)
                {
                    continue;
                }
            }

            if (filter.Class != Classes.ClassList.Default)
            {
                if (filter.Class != card.CardClass)
                {
                    continue;
                }
            }

            if (filter.Tag != Tags.Default)
            {
                if (!card.Tags.Contains(filter.Tag))
                {
                    continue;
                }
            }

            if (filter.Resource != CardResources.Neutral)
            {
                if (!card.Resources.Contains(filter.Resource))
                {
                    continue;
                }
            }

            if (filter.ScenarioCreated.HasValue)
            {
                if (!filter.ScenarioCreated.Value != string.IsNullOrWhiteSpace(card.CreatedByName))
                {
                    continue;
                }
            }

            if (filter.CardType != CardTypes.Default)
            {
                if (filter.CardType != card.Type)
                {
                    continue;
                }
            }

            //Flag to determine if failed the filter. Sets to false to assume that the card succceeds the filter
            bool intFilterFlag = false;

            //Loops through each of the int filters
            foreach (var intFilter in filter.IntFilters)
            {
                //Checks that the filter is not a none value
                if (intFilter.Value.Key != IntValueFilter.None)
                {
                    int?value = null;
                    //Sets the value to the required property of the card. Converts cards to a different type if required
                    switch (intFilter.Key)
                    {
                    case CardListFilter.IntFilterTypes.Cost:
                        //Convert total cost to a positive, as total resource provides a negative value
                        value = -card.TotalResource;
                        break;

                    case CardListFilter.IntFilterTypes.Attack:
                        if (card.Type == CardTypes.Unit)
                        {
                            value = ((Unit)card).GetStat(Unit.StatTypes.Attack);
                        }
                        break;

                    case CardListFilter.IntFilterTypes.Health:
                        if (card.Type == CardTypes.Unit)
                        {
                            value = ((Unit)card).GetStat(Unit.StatTypes.MaxHealth);
                        }
                        break;

                    case CardListFilter.IntFilterTypes.Range:
                        if (card.Type == CardTypes.Unit)
                        {
                            value = ((Unit)card).GetStat(Unit.StatTypes.Range);
                        }
                        break;

                    case CardListFilter.IntFilterTypes.Speed:
                        if (card.Type == CardTypes.Unit)
                        {
                            value = ((Unit)card).GetStat(Unit.StatTypes.Speed);
                        }
                        break;

                    case CardListFilter.IntFilterTypes.SpellRange:
                        if (card.Type == CardTypes.Unit)
                        {
                            value = ((Spell)card).SpellRange;
                        }
                        break;

                    case CardListFilter.IntFilterTypes.Durability:
                        if (card.Type == CardTypes.Unit)
                        {
                            value = ((Item)card).Durability;
                        }
                        break;

                    default:
                        throw new Exception("Not a valid filter type");
                    }

                    //Sets the value filter to the given filter
                    var intvalueFilter = intFilter.Value;

                    //If highest or lowest, need to record the current highest or lowest value
                    if (intFilter.Value.Key == IntValueFilter.Highest || intFilter.Value.Key == IntValueFilter.Lowest)
                    {
                        //If the key does not exist in the highest/lowest record, adds it
                        if (!intValueTracker.ContainsKey(intFilter.Key))
                        {
                            intValueTracker.Add(intFilter.Key, value);
                        }

                        //Creates the value filter as the recorded highest value
                        intvalueFilter = new KeyValuePair <IntValueFilter, int?>
                                             (intFilter.Value.Key, intValueTracker.FirstOrDefault(x => x.Key == intFilter.Key).Value);
                    }

                    //Determines if the recorded value has a value
                    if (value.HasValue)
                    {
                        //If the value fails the filter sets the flag to true and breaks from the loop, which will then continue the loop through the cards
                        if (!IntValueFilterer.CheckIntValueFilter(value.Value, intvalueFilter))
                        {
                            intFilterFlag = true;
                            break;
                        }
                        else
                        {
                            //If succeeds the filter, means need to check the highest or lowest value to futher filter the card list
                            if (intFilter.Value.Key == IntValueFilter.Highest || intFilter.Value.Key == IntValueFilter.Lowest)
                            {
                                //If the value is not equal to the current highest or lowest value, means that it has beat the previous highest or lowest card in the comparison
                                if (intFilter.Value.Value != value)
                                {
                                    //Removes the previous highest or lowest value from the record, then adds the new record to keep it for the next card iteration
                                    intValueTracker.Remove(intFilter.Key);
                                    intValueTracker.Add(intFilter.Key, value);

                                    //Removes all the cards in the filtered card list which share the same property value of the previous highest or lowest value
                                    switch (intFilter.Key)
                                    {
                                    case CardListFilter.IntFilterTypes.Cost:
                                        filteredCardList.RemoveAll(x => x.TotalResource == value);
                                        break;

                                    case CardListFilter.IntFilterTypes.Attack:
                                        filteredCardList.RemoveAll(x => ((Unit)x).GetStat(Unit.StatTypes.Attack) == value);
                                        break;

                                    case CardListFilter.IntFilterTypes.Health:
                                        filteredCardList.RemoveAll(x => ((Unit)x).GetStat(Unit.StatTypes.MaxHealth) == value);
                                        break;

                                    case CardListFilter.IntFilterTypes.Range:
                                        filteredCardList.RemoveAll(x => ((Unit)x).GetStat(Unit.StatTypes.Range) == value);
                                        break;

                                    case CardListFilter.IntFilterTypes.Speed:
                                        filteredCardList.RemoveAll(x => ((Unit)x).GetStat(Unit.StatTypes.Speed) == value);
                                        break;

                                    case CardListFilter.IntFilterTypes.SpellRange:
                                        filteredCardList.RemoveAll(x => ((Spell)x).SpellRange == value);
                                        break;

                                    case CardListFilter.IntFilterTypes.Durability:
                                        filteredCardList.RemoveAll(x => ((Item)x).Durability == value);
                                        break;

                                    default:
                                        throw new Exception("Not a valid filter type");
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (intFilterFlag)
            {
                continue;
            }

            //If card passes all filters, then adds the card to the filtered card list
            filteredCardList.Add(card);
        }

        return(new CardList(filteredCardList));
    }