Example #1
0
 public void ClearBoard(IDeckDict <SolitaireCard> thisCol)
 {
     if (thisCol.Count != CardsNeededToBegin)
     {
         throw new BasicBlankException($"Needs {CardsNeededToBegin}, not {thisCol.Count}");
     }
     if (thisCol.Any(items => items.Value != EnumCardValueList.Queen))
     {
         throw new BasicBlankException("Only queens can be used");
     }
     thisCol.First().Angle = EnumRotateCategory.RotateOnly90;
     thisCol[2].Angle = EnumRotateCategory.RotateOnly90;
     CardList.ReplaceRange(thisCol);
 }
 public void ClearBoard(IDeckDict <SolitaireCard> thisList)
 {
     if (thisList.Count != 12)
     {
         throw new BasicBlankException("Must have 12 cards");
     }
     ClearBoard();
     _thisMod.Score = thisList.Count;
     ClockList !.ForEach(thisClock =>
     {
         thisClock.CardList.ReplaceAllWithGivenItem(thisList.First());
         thisClock.IsEnabled = true;
         thisList.RemoveFirstItem();
     });
 }
Example #3
0
        public bool CanAddSet(IDeckDict <RegularRummyCard> thisCol)
        {
            if (SetList.Count == 0)
            {
                return(true); //you can always do a first one.
            }
            RegularRummyCard thisCard = thisCol.First();

            foreach (var thisSet in SetList)
            {
                var oldCard = thisSet.HandList.First();
                if (thisCard.Suit == oldCard.Suit)
                {
                    return(false);
                }
            }
            return(true);
        }
Example #4
0
        public async Task PickupFromDiscardAsync(IDeckDict <RegularRummyCard> thisCol)
        {
            var thisCard = thisCol.First();

            _gameContainer.PreviousCard = thisCard.Deck;
            _model !.DiscardList1 !.RemoveFromPoint(thisCard.Deck);
            thisCol.ForEach(tempCard =>
            {
                tempCard.Drew = true;
            });
            SingleInfo !.MainHandList.AddRange(thisCol);
            SaveRoot !.MoreThanOne = thisCol.Count > 1;
            if (SingleInfo.PlayerCategory == EnumPlayerCategory.Self)
            {
                SortCards();
            }
            _gameContainer.AlreadyDrew = true; //this counts as already drawing too.
            await ContinueTurnAsync();
        }
Example #5
0
 public void NewList(IDeckDict <D> whatList)
 {
     if (whatList.Count == 0)
     {
         return;
     }
     CurrentCard            = whatList.First();
     CurrentCard.IsUnknown  = false;
     CurrentCard.IsSelected = false;
     CurrentCard.Drew       = false;
     whatList.RemoveFirstItem(); //try this way.  could fix at least one of the problems.
     whatList.ForEach(Items =>
     {
         Items.IsSelected = false;
         Items.Drew       = false;
     });
     _objectList.ReplaceRange(whatList); // because we are replacing the entire range.
     _previousNum = _objectList.Count;
 }
Example #6
0
        public void CreateSet(IDeckDict <TileInfo> thisCol, EnumWhatSets whatType)
        {
            _setType = whatType;
            _isNew   = true;
            TileRummySaveInfo saveRoot = cons !.Resolve <TileRummySaveInfo>();

            if (thisCol.Count == 0)
            {
                throw new BasicBlankException("There must be at least one item to create a new set");
            }
            foreach (var tempTile in thisCol)
            {
                saveRoot.TilesFromField.RemoveSpecificItem(tempTile.Deck);// if not there, ignore
            }
            if (_setType == EnumWhatSets.Kinds)
            {
                HandList.ReplaceRange(thisCol);
                return;
            }
            var wildCol = GetWildList(thisCol);
            int VeryFirst;

            VeryFirst = thisCol.First().Number;
            int veryLast;

            veryLast = thisCol.Last().Number;
            int firstNum;
            int lastNum;

            firstNum = VeryFirst;
            lastNum  = veryLast;
            int x;
            int y;
            int WildNum = default;

            y = 1;
            var loopTo = thisCol.Count;

            for (x = 2; x <= loopTo; x++)
            {
                y        += 1;
                firstNum += 1;
                var thisTile = thisCol[y - 1];
                if (thisTile.Number != firstNum)
                {
                    WildNum        += 1;
                    thisTile        = wildCol[WildNum - 1];
                    thisTile.Number = firstNum;
                    if (thisTile.Number == 14)
                    {
                        thisTile.Number = VeryFirst - 1;
                    }
                    y -= 1;
                }
            }
            var Temps = (from items in thisCol
                         orderby items.Number
                         select items).ToList();

            HandList.ReplaceRange(Temps);
        }
        //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);
        }
        public void CreateSet(IDeckDict <ChinazoCard> thisList, RummyProcesses <EnumSuitList, EnumColorList, ChinazoCard> .EnumRummyType whichSet, bool useSecond)
        {
            _whatSet   = whichSet;
            _useSecond = useSecond;
            var wildCol = thisList.Where(items => items.IsObjectWild == true).ToRegularDeckDict();

            thisList.ForEach(thisCard =>
            {
                thisCard.IsSelected = false;
                thisCard.Drew       = false;
            });
            if (_whatSet != RummyProcesses <EnumSuitList, EnumColorList, ChinazoCard> .EnumRummyType.Runs)
            {
                HandList.ReplaceRange(thisList);
                if (HandList.Count == 0)
                {
                    throw new BasicBlankException("the hand list was blank");
                }
                return;
            }
            EnumSuitList suitOfSet      = thisList.First(items => items.IsObjectWild == false).Suit;
            int          originalNumber = thisList.Count;
            var          tempCol        = thisList.Where(items => items.IsObjectWild == false).ToRegularDeckDict();

            if (useSecond == true)
            {
                tempCol = tempCol.OrderBy(items => items.SecondNumber).ToRegularDeckDict();
            }
            int firstNum;

            if (useSecond == true)
            {
                tempCol.First().UsedAs = (int)tempCol.First().SecondNumber;
            }
            else
            {
                tempCol.First().UsedAs = (int)tempCol.First().Value;
            }
            firstNum = tempCol.First().UsedAs;
            if (firstNum > 12)
            {
                throw new BasicBlankException("The first number cannot be higher than 12 for runs.");
            }
            tempCol.Last().UsedAs = (int)tempCol.Last().Value;
            int         whatFirst = firstNum;
            int         lastNum   = tempCol.Last().UsedAs;
            int         y         = tempCol.Count;
            ChinazoCard tempCard;

            for (int x = 2; x <= y; x++)
            {
                firstNum += 1;
                tempCard  = tempCol[x - 1];
                if ((int)tempCard.Value != firstNum)
                {
                    tempCard        = wildCol.First();
                    tempCard.UsedAs = firstNum;
                    tempCard.Suit   = suitOfSet;          //hopefully that is okay (?)
                    tempCol.Add(tempCard);
                    wildCol.RemoveSpecificItem(tempCard); //hopefully still works.
                    x--;
                }
                else
                {
                    if (useSecond == true)
                    {
                        tempCard.UsedAs = (int)tempCard.SecondNumber;
                    }
                    else
                    {
                        tempCard.UsedAs = (int)tempCard.Value;
                    }
                }
                if (tempCard.UsedAs > 14)
                {
                    throw new BasicBlankException("The use as cannot be higher than 14 ever");
                }
            }
            if (wildCol.Count > 0)
            {
                lastNum += 1;
                for (int x = lastNum; x <= 14; x++)
                {
                    if (wildCol.Count == 0)
                    {
                        break;
                    }
                    tempCard        = wildCol.First();
                    tempCard.UsedAs = x;
                    tempCard.Suit   = suitOfSet;
                    tempCol.Add(tempCard);
                    wildCol.RemoveSpecificItem(tempCard);
                }
                whatFirst--;
                for (int x = whatFirst; x >= 1; x += -1)
                {
                    if (wildCol.Count == 0)
                    {
                        break;
                    }
                    tempCard        = wildCol.First(); //hopefully still okay.
                    tempCard.UsedAs = x;
                    tempCard.Suit   = suitOfSet;
                    tempCol.Add(tempCard);
                    wildCol.RemoveSpecificItem(tempCard);
                }
                if (tempCol.Count != originalNumber)
                {
                    throw new BasicBlankException("Must have the same number of cards sent for creating set");
                }
            }
            if (tempCol.Any(items => items.UsedAs == 0))
            {
                throw new BasicBlankException("You must have accounted for all used.  Rethink");
            }
            var tempList = tempCol.OrderBy(items => items.UsedAs).ToRegularDeckDict();

            HandList.ReplaceRange(tempList);
            if (HandList.Count == 0)
            {
                throw new BasicBlankException("HandList Blank");
            }
            _firstNumber = HandList.First().UsedAs;
        }