示例#1
0
        public bool CardContainsRummy(int deck, IDeckDict <RegularRummyCard> newSet)
        {
            int x;
            var thisCard = _gameContainer.DeckList !.GetSpecificItem(deck);
            int plays;

            foreach (var thisSet in _model !.MainSets1 !.SetList)
            {
                for (x = 1; x <= 2; x++)
                {
                    plays = thisSet.PositionToPlay(thisCard);
                    if (plays > 0)
                    {
                        return(true);
                    }
                }
            }
            if (newSet.Count < 4)
            {
                return(false); //because still needs one for discard.
            }
            int manys = newSet.Count(items => items.Value == thisCard.Value);

            if (manys >= 3)
            {
                return(true); //other cases are covered.
            }
            DeckRegularDict <RegularRummyCard> mainList;

            do
            {
                mainList = newSet.ToRegularDeckDict();
                var tempCol = _rummys !.WhatNewRummy(mainList, 3, RummyProcesses <EnumSuitList, EnumColorList, RegularRummyCard> .EnumRummyType.Runs, false);
                if (tempCol.Count == 0)
                {
                    return(false);
                }
                if (tempCol.Count == newSet.Count)
                {
                    return(false); //because nothing left to discard.
                }
                if (tempCol.Any(Items => Items.Deck == deck))
                {
                    return(true);
                }
                newSet.RemoveGivenList(tempCol, System.Collections.Specialized.NotifyCollectionChangedAction.Remove); //hopefully that works.
            } while (true);
        }