public DeckRegularDict <MonasteryCardInfo> RunList(DeckRegularDict <MonasteryCardInfo> thisCol, EnumRunType runType)
        {
            var tempCol = PopulateTempCol(thisCol, out DeckRegularDict <MonasteryCardInfo> aceList);
            DeckRegularDict <MonasteryCardInfo> output = new DeckRegularDict <MonasteryCardInfo>();
            var thisCard  = tempCol.First();
            int minNumber = (int)thisCard.Value;
            int maxNumber = minNumber + thisCol.Count - 1;

            if (maxNumber > 13)
            {
                thisCard  = tempCol.Last();
                maxNumber = (int)thisCard.Value;
                minNumber = maxNumber - thisCol.Count + 1;
            }
            EnumSuitList suitNeeded;

            if (runType == EnumRunType.Color)
            {
                if (thisCard.Color == EnumColorList.Red)
                {
                    suitNeeded = EnumSuitList.Diamonds;
                }
                else
                {
                    suitNeeded = EnumSuitList.Clubs;
                }
            }
            else if (runType == EnumRunType.Suit)
            {
                suitNeeded = thisCard.Suit;
            }
            else
            {
                suitNeeded = EnumSuitList.Diamonds;
            }
            int currentNum = minNumber;

            thisCol.Count.Times(x =>
            {
                if (tempCol.Any(items => (int)items.Value == currentNum) == false)
                {
                    thisCard     = EntireList.First(items => items.Suit == suitNeeded && (int)items.Value == currentNum);
                    var nextCard = new MonasteryCardInfo();
                    nextCard.Populate(thisCard.Deck);
                    nextCard.Temp = thisCard.Deck;        //this too i think.
                    nextCard.Deck = aceList.First().Deck; //this is what i had to do now.
                    aceList.RemoveFirstItem();            //has to use the deck of the ace to stop the id problems.
                    output.Add(nextCard);
                }
                else
                {
                    thisCard = tempCol.Single(items => (int)items.Value == currentNum);
                    tempCol.RemoveSpecificItem(thisCard);
                    output.Add(thisCard);
                }
                currentNum++;
            });
            return(output);
        }
        private DeckRegularDict <HeapSolitaireCardInfo> GetFirstList()
        {
            DeckRegularDict <HeapSolitaireCardInfo> output = new DeckRegularDict <HeapSolitaireCardInfo>();
            EnumColorList newColor  = (EnumColorList)_rs.GetRandomNumber(2);
            int           newNumber = 7;

            do
            {
                if (output.Count < 13)
                {
                    if (newColor == EnumColorList.Black)
                    {
                        newColor = EnumColorList.Red;
                    }
                    else
                    {
                        newColor = EnumColorList.Black;
                    }
                    var finalCard = _cardList.First(items => (int)items.Value == newNumber && items.Color == newColor);
                    output.Add(finalCard);
                    _cardList.RemoveSpecificItem(finalCard);
                    if (output.Count == 13)
                    {
                        return(output);
                    }
                    newNumber++;
                    if (newNumber > 13)
                    {
                        newNumber = 1;
                    }
                }
            } while (true);
        }
Ejemplo n.º 3
0
 public bool IsValidMove(DeckRegularDict <RegularSimpleCard> thisCol)
 {
     if (Test !.AllowAnyMove == true)
     {
         return(true);
     }
     return(thisCol.First().Value == thisCol.Last().Value);
 }
        //private readonly BasicData _thisData;
        public void CreateSet(IDeckDict <Phase10CardInformation> thisCol, EnumWhatSets whatType)
        {
            _whatSet = whatType;
            thisCol.ForEach(items =>
            {
                items.Drew       = false;
                items.IsSelected = false;
            });
            if (_whatSet != EnumWhatSets.Runs)
            {
                HandList.ReplaceRange(thisCol);
                return;
            }
            DeckRegularDict <Phase10CardInformation> tempList = thisCol.ToRegularDeckDict();
            DeckRegularDict <Phase10CardInformation> wildCol  = thisCol.Where(items => items.CardCategory == EnumCardCategory.Wild).ToRegularDeckDict();

            thisCol.KeepConditionalItems(items => items.CardCategory == EnumCardCategory.None);
            int firstNum  = thisCol.First().Number;
            int whatFirst = firstNum;
            int lastNum   = thisCol.Last().Number;
            int x;
            var loopTo = thisCol.Count;
            Phase10CardInformation thisCard;

            for (x = 2; x <= loopTo; x++)
            {
                firstNum += 1;
                thisCard  = thisCol[x - 1];
                if (thisCard.Number != firstNum)
                {
                    thisCard        = wildCol.First();
                    thisCard.Number = firstNum; // will put back when new round (?)
                    wildCol.RemoveSpecificItem(thisCard);
                    x -= 1;
                }
            }
            if (wildCol.Count > 0)
            {
                lastNum += 1;
                for (x = lastNum; x <= 11; x++)
                {
                    if (wildCol.Count == 0)
                    {
                        break;
                    }
                    thisCard        = wildCol.First();
                    thisCard.Number = x;
                    wildCol.RemoveSpecificItem(thisCard);
                }
                whatFirst -= 1;
                for (x = whatFirst; x >= 2; x += -1)
                {
                    if (wildCol.Count == 0)
                    {
                        break;
                    }
                    thisCard        = wildCol.First();
                    thisCard.Number = x;
                    wildCol.RemoveSpecificItem(thisCard);
                }
            }
            var Fins = tempList.OrderBy(Items => Items.Number);

            HandList.ReplaceRange(Fins);
        }
        private int WhoWonTrick(DeckObservableDict <HorseshoeCardGameCardInformation> thisCol)
        {
            if (thisCol.Count != 4)
            {
                throw new BasicBlankException("Must have 4 cards for the trick list to see who won");
            }
            var thisCard           = thisCol.First();
            int begins             = thisCard.Player;
            EnumCardValueList nums = thisCard.Value;

            if (thisCol.All(Items => Items.Value == nums))
            {
                return(begins);
            }
            DeckRegularDict <HorseshoeCardGameCardInformation> playerStarted = new DeckRegularDict <HorseshoeCardGameCardInformation>();
            DeckRegularDict <HorseshoeCardGameCardInformation> otherPlayer   = new DeckRegularDict <HorseshoeCardGameCardInformation>();

            playerStarted.Add(thisCol.First());
            playerStarted.Add(thisCol.Last());
            otherPlayer.Add(thisCol[1]);
            otherPlayer.Add(thisCol[2]);
            HorseshoeCardGameCardInformation firstCard  = playerStarted.First();
            HorseshoeCardGameCardInformation secondCard = playerStarted.Last();
            EnumSuitList      whichSuit = firstCard.Suit;
            EnumCardValueList pairAmount;
            EnumCardValueList highestSuitNumber = EnumCardValueList.None;
            int possibleWinPlayer = 0;

            if (firstCard.Value == secondCard.Value)
            {
                pairAmount = firstCard.Value;
            }
            else
            {
                pairAmount = EnumCardValueList.None;
                var card = thisCol.Where(x => x.Suit == whichSuit).OrderByDescending(x => x.Value).Take(1).Single();
                highestSuitNumber = card.Value;
                possibleWinPlayer = card.Player;
                //if (secondCard.Value > firstCard.Value && secondCard.Suit == firstCard.Suit)
                //    highestSuitNumber = secondCard.Value;
                //else if (secondCard.Suit == firstCard.Suit)
                //    highestSuitNumber = firstCard.Value;
            }
            firstCard  = otherPlayer.First();
            secondCard = otherPlayer.Last();
            if (firstCard.Value != secondCard.Value && pairAmount > 0)
            {
                return(begins);
            }
            if (firstCard.Value == secondCard.Value)
            {
                if (firstCard.Value > pairAmount)
                {
                    if (begins == 1)
                    {
                        return(2);
                    }
                    return(1);
                }
            }
            if (pairAmount > 0)
            {
                return(begins);
            }

            if (possibleWinPlayer == 0)
            {
                throw new BasicBlankException("Sombody had to win it");
            }
            return(possibleWinPlayer);
            //if (firstCard.Suit == whichSuit)
            //{
            //    if (firstCard.Value > highestSuitNumber)
            //    {
            //        if (begins == 1)
            //            return 2;
            //        return 1;
            //    }
            //}
            //if (secondCard.Suit == whichSuit)
            //{
            //    if (secondCard.Value > highestSuitNumber)
            //    {
            //        if (begins == 1)
            //            return 2;
            //        return 1;
            //    }
            //}
            //return begins;
        }