public void LoadBarCards(IDeckDict <SnagCardGameCardInformation> thisList)
        {
            if (_wasSaved == false && thisList.Count != 5)
            {
                throw new BasicBlankException("Must have 5 cards for the bar.");
            }
            if (_wasSaved == true && thisList.Count > 5)
            {
                throw new BasicBlankException("The bar can never have more than 5 cards");
            }
            bool rets = NeedsReverse();

            if (rets == true)
            {
                thisList.Reverse();
            }
            DeckRegularDict <SnagCardGameCardInformation> tempList = new DeckRegularDict <SnagCardGameCardInformation>();

            thisList.ForEach(thisCard =>
            {
                var newCard = new SnagCardGameCardInformation();
                newCard.Populate(thisCard.Deck);
                newCard.Angle = EnumRotateCategory.RotateOnly90;
                tempList.Add(newCard);
            });
            HandList.ReplaceRange(tempList);
        }
        public void LoadDummyCards(IDeckDict <RookCardInformation> thisList, RookMainGameClass mainGame)
        {
            if (thisList.Count != 12)
            {
                throw new BasicBlankException("Must have 12 cards for dummy cards");
            }
            if (mainGame.PlayerList.Count() == 3)
            {
                throw new BasicBlankException("There is no dummy hand because there are 3 players already");
            }
            int x = 0;

            thisList.ForEach(thisCard =>
            {
                x++;
                if (x < 7)
                {
                    thisCard.IsUnknown = false;
                }
                else
                {
                    thisCard.IsUnknown = true;
                }
            });
            HandList.ReplaceRange(thisList);
        }
示例#3
0
        public void ReshuffleFirstObjects(IDeckDict <D> thisList, int startAt, int endAt)
        {
            CheckRandom();
            int x = 0;
            int index;
            int ask1;

            endAt = endAt - thisList.Count + 1;
            int increasedEnd = 0;

            thisList.ForEach(items =>
            {
                index = _privateDict.IndexOf(items);
                if (index <= endAt)
                {
                    increasedEnd++;
                }
            });
            endAt += increasedEnd;
            thisList.ForEach(items =>
            {
                index = _privateDict.IndexOf(items);
                if (index == -1)
                {
                    throw new BasicBlankException("Item not found to reshuffle the card");
                }
                if (index < startAt || index > endAt)
                {
                    ask1 = _rs !.GetRandomNumber(endAt, startAt);
                    _privateDict.MoveItem(items, ask1);
                }
                x++;
                endAt--;
            });
        }
示例#4
0
        public void PopulateNewCards(IDeckDict <PokerCardInfo> thisList)
        {
            DisplayCard thisDisplay;

            if (PokerList.Count == 0)
            {
                CustomBasicList <DisplayCard> newList = new CustomBasicList <DisplayCard>();
                if (thisList.Count != 5)
                {
                    throw new BasicBlankException("Must have 5 cards for the poker hand");
                }
                thisList.ForEach(thisCard =>
                {
                    thisDisplay             = new DisplayCard();
                    thisDisplay.CurrentCard = thisCard;
                    newList.Add(thisDisplay);
                });
                PokerList.ReplaceRange(newList);
                return;
            }
            var tempList = PokerList.Where(items => items.WillHold == false).ToCustomBasicList();

            if (tempList.Count != thisList.Count)
            {
                throw new BasicBlankException("Mismatch for populating new cards");
            }
            int x = 0;

            tempList.ForEach(temps =>
            {
                var thisCard      = thisList[x];
                temps.CurrentCard = thisCard;
                x++;
            });
        }
        private bool IsMultiMove(CribbageCombos thisCombo, IDeckDict <CribbageCard> thisCol)
        {
            var newCol = thisCol.ToRegularDeckDict();

            newCol.Add(StartCard());
            var whatNewRummy = _rummys !.WhatNewRummy(newCol, thisCombo.NumberInStraight, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Runs, false);

            if (whatNewRummy.Count == 0)
            {
                return(false);
            }
            if (whatNewRummy.Count > thisCombo.NumberInStraight)
            {
                return(false);
            }
            whatNewRummy.ForEach(thisCard => thisCard.HasUsed = true);
            EnumCardValueList firstNumber  = whatNewRummy.First().Value;
            EnumCardValueList secondNumber = whatNewRummy.Last().Value;
            var lastTemp = newCol.ToRegularDeckDict();

            lastTemp.KeepConditionalItems(items => items.Value >= firstNumber || items.Value <= secondNumber);
            newCol.Clear();
            newCol.AddRange(lastTemp);
            whatNewRummy = _rummys.WhatNewRummy(newCol, thisCombo.NumberForKind, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false);
            if (whatNewRummy.Count == 0 || whatNewRummy.Count > thisCombo.NumberForKind)
            {
                thisCol.ForEach(thisCard => thisCard.HasUsed = false);
                StartCard().HasUsed = false;
                return(false);
            }
            if (thisCombo.DoublePairNeeded == true)
            {
                lastTemp.KeepConditionalItems(items => items.Value != whatNewRummy.First().Value);
                newCol.Clear();
                newCol.AddRange(lastTemp);
                whatNewRummy = _rummys.WhatNewRummy(newCol, thisCombo.NumberForKind, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false);
                if (whatNewRummy.Count == 0 || whatNewRummy.Count > thisCombo.NumberForKind)
                {
                    thisCol.ForEach(thisCard => thisCard.HasUsed = false);
                    StartCard().HasUsed = false;
                    return(false);
                }
                whatNewRummy.ForEach(thisCard => thisCard.HasUsed = true);
            }
            return(true);
        }
示例#6
0
 public void InsertBeginningCards(IDeckDict <D> testCards) //this is needed in cases where we need some cards to be at the beginning of the deck.  one hint was tee it up.
 {
     testCards.ForEach(tempCard =>
     {
         var ourCard = _objectList.GetSpecificItem(tempCard.Deck);
         _objectList.RemoveSpecificItem(ourCard);
         _objectList.InsertBeginning(tempCard);
     });
 }
 public static void SelectMaxOne <D>(this IDeckDict <D> thisList, D thisItem) where D : IDeckObject
 {
     if (thisItem.IsSelected == true)
     {
         thisItem.IsSelected = false;
         return;
     }
     thisList.ForEach(items => items.IsSelected = false);
     thisItem.IsSelected = true;
 }
示例#8
0
 //private void FinishClearing()
 //{
 //    thisMod!.GolfHand1!.Visible = false;
 //    thisMod.HiddenCards1!.Visible = false;
 //    thisMod.KnockedVisible = false;
 //    thisMod.Deck1!.Visible = false;
 //    thisMod.Pile1!.Visible = false;
 //    thisMod.Pile2!.Visible = false;
 //    thisMod.ChooseFirstCardsVisible = true;
 //    Visible = true;
 //    IsEnabled = true;
 //}
 public void ClearBoard(IDeckDict <RegularSimpleCard> thisList)
 {
     if (thisList.Count != 4)
     {
         throw new BasicBlankException("The card list must have 4 cards");
     }
     thisList.ForEach(thisCard =>
     {
         thisCard.IsUnknown = true;
     });
     ObjectList.ReplaceRange(thisList);
     //FinishClearing();
 }
 public void CreateNewSet(IDeckDict <RegularRummyCard> thisCol)
 {
     if (thisCol.Count < 2 || thisCol.Count > 4)
     {
         throw new BasicBlankException("A set must have 2 to 4 cards");
     }
     _player = _gameContainer.WhoTurn;
     thisCol.ForEach(thisCard =>
     {
         thisCard.Drew       = false;
         thisCard.IsSelected = false;
     });
     HandList.ReplaceRange(thisCol);
 }
        public void CreateSet(IDeckDict <MonasteryCardInfo> thisCol, EnumWhatSets whatSet)
        {
            _setType = whatSet;
            DeckRegularDict <MonasteryCardInfo> tempList = new DeckRegularDict <MonasteryCardInfo>();

            thisCol.ForEach(thisCard =>
            {
                var newCard = new MonasteryCardInfo();
                newCard.Populate(thisCard.Temp); //hopefully this works.
                newCard.Deck = thisCard.Deck;
                tempList.Add(newCard);
            });
            HandList.ReplaceRange(tempList);
        }
 public void CreateNewMoon(IDeckDict <GalaxyCardGameCardInformation> thisCol, EnumWhatSets whatSet)
 {
     WhatSet = whatSet;
     if (WhatSet == 0)
     {
         throw new BasicBlankException("WhatSet cannot be 0 when creating a set");
     }
     thisCol = thisCol.OrderBy(items => items.Value).ToRegularDeckDict();
     thisCol.ForEach(thisCard =>
     {
         thisCard.Drew       = false;
         thisCard.IsSelected = false;
     });
     HandList.ReplaceRange(thisCol);
 }
示例#12
0
        async Task IGiveTaxationProcesses.GiveCardsForTaxationAsync(IDeckDict <FluxxCardInformation> list)
        {
            if (_gameContainer !.CurrentAction == null)
            {
                throw new BasicBlankException("Must have a current action in order to give cards for taxation");
            }
            if (_gameContainer.CurrentAction.Deck != EnumActionMain.Taxation)
            {
                throw new BasicBlankException("The current action must be taxation");
            }
            _gameContainer.SingleInfo = _gameContainer.PlayerList !.GetOtherPlayer();
            if (_gameContainer.SingleInfo.CanSendMessage(_gameContainer.BasicData !))
            {
                await _gameContainer.Network !.SendAllAsync("taxation", list.GetDeckListFromObjectList());
            }
            _gameContainer.SingleInfo = _gameContainer.PlayerList.GetWhoPlayer();
            list.ForEach(thisCard => thisCard.Drew = true);
            _gameContainer.SingleInfo.MainHandList.AddRange(list);
            if (_gameContainer.SingleInfo.PlayerCategory == EnumPlayerCategory.Self)
            {
                _gameContainer.SortCards !();
            }
            if (_gameContainer.LoadPlayAsync == null)
            {
                throw new BasicBlankException("Nobody is loading the play button on main screen for taxation.  Rethink");
            }
            await _gameContainer.LoadPlayAsync();

            do
            {
                _gameContainer.OtherTurn = await _gameContainer.PlayerList.CalculateOtherTurnAsync();

                if (_gameContainer.OtherTurn == 0)
                {
                    _gameContainer.CurrentAction = null;
                    break;
                }
                _gameContainer.SingleInfo = _gameContainer.PlayerList.GetOtherPlayer();
                if (_gameContainer.SingleInfo.MainHandList.Count > 0)
                {
                    break;
                }
            } while (true);
            _gameContainer.SingleInfo = _gameContainer.PlayerList.GetWhoPlayer();
            await _processes.AnalyzeQueAsync();
        }
示例#13
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();
        }
示例#14
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;
 }
        private bool HadFullHouse(IDeckDict <CribbageCard> thisCol)
        {
            var newCol       = thisCol.Where(items => items.HasUsed == false).ToRegularDeckDict();
            var whatNewRummy = _rummys !.WhatNewRummy(newCol, 3, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false);

            if (whatNewRummy.Count == 0 || whatNewRummy.Count > 3)
            {
                return(false);
            }
            whatNewRummy.ForEach(thisCard => thisCard.HasUsed = true);
            newCol.RemoveAllOnly(items => items.HasUsed == true);
            whatNewRummy = _rummys.WhatNewRummy(newCol, 2, RummyProcesses <EnumSuitList, EnumColorList, CribbageCard> .EnumRummyType.Sets, false);
            if (whatNewRummy.Count == 0 || whatNewRummy.Count > 2)
            {
                thisCol.ForEach(thisCard => thisCard.HasUsed = false);
                return(false);
            }
            whatNewRummy.ForEach(thisCard => thisCard.HasUsed = true);
            return(true);
        }
        public void CreateNewSet(IDeckDict <RegularRummyCard> thisCol, EnumWhatSets whatSet, bool useSecond)
        {
            _useSecond = useSecond;
            _setType   = whatSet;
            DeckRegularDict <RegularRummyCard> output;

            if (useSecond == true)
            {
                output = thisCol.OrderBy(items => items.SecondNumber).ToRegularDeckDict();
            }
            else
            {
                output = thisCol.OrderBy(items => items.Value).ToRegularDeckDict();
            }
            thisCol.ForEach(thisCard =>
            {
                thisCard.Player     = _gameContainer.WhoTurn;
                thisCard.Drew       = false;
                thisCard.IsSelected = false;
            });
            HandList.ReplaceRange(output);
        }
        private CustomBasicCollection <CribbageCombos> ListCribbageCombos(IDeckDict <CribbageCard> thisCol, bool fromCrib)
        {
            CustomBasicCollection <CribbageCombos> output = new CustomBasicCollection <CribbageCombos>();
            var  mostSuits = thisCol.GroupOrderDescending(items => items.Suit);
            bool hadFourFlush;
            bool hadFiveFlush;
            var  startCard = StartCard();

            startCard.HasUsed = false;
            thisCol.ForEach(thisCard => thisCard.HasUsed = false);

            if (mostSuits.First().Count() == 4 && startCard.Suit == mostSuits.First().Key)
            {
                hadFiveFlush = true;
                hadFourFlush = false;
            }
            else if (mostSuits.First().Count() == 4 && fromCrib == false)
            {
                hadFourFlush = true;
                hadFiveFlush = false; //originally was true.
            }
            else
            {
                hadFourFlush = false;
                hadFiveFlush = false;
            }
            bool           hadMultiMove = false;
            int            pairss       = 0;
            bool           hadLongerRun = false;
            bool           hadStraight  = false;
            bool           hadKind      = false;
            int            fifs;
            CribbageCombos newCombo;

            ComboList.ForEach(thisCombo =>
            {
                if (thisCombo.NumberNeeded == 15)
                {
                    fifs = Find15Combos(thisCol);
                    if (fifs > 0)
                    {
                        newCombo             = new CribbageCombos();
                        newCombo.Description = "Fifteens";
                        newCombo.Points      = fifs * 2;
                        output.Add(newCombo);
                    }
                }
                else if (thisCombo.IsFlush == true)
                {
                    if (thisCombo.CardsToUse == 5 && hadFiveFlush == true)
                    {
                        output.Add(thisCombo);
                    }
                    else if (thisCombo.CardsToUse == 4 && hadFourFlush == true)
                    {
                        output.Add(thisCombo);
                    }
                }

                else if (thisCombo.JackStatus == EnumJackType.Nob)
                {
                    if (thisCol.Any(items => items.Value == EnumCardValueList.Jack && items.Suit == startCard.Suit && startCard.Value != EnumCardValueList.Jack))
                    {
                        output.Add(thisCombo);
                    }
                }
                else if (thisCombo.JackStatus == EnumJackType.Heels)
                {
                    if (thisCol.Any(items => items.Suit == startCard.Suit && startCard.Value == EnumCardValueList.Jack))
                    {
                        output.Add(thisCombo);
                    }
                }
                else if (thisCombo.IsFullHouse)
                {
                    if (HadFullHouse(thisCol))
                    {
                        output.Add(thisCombo);
                    }
                }

                else if (thisCombo.NumberForKind > 0 && thisCombo.NumberInStraight > 0)
                {
                    if (hadMultiMove == false)
                    {
                        hadMultiMove = IsMultiMove(thisCombo, thisCol);
                        if (hadMultiMove == true)
                        {
                            output.Add(thisCombo);
                        }
                    }
                }

                else if (thisCombo.NumberInStraight == 4 && hadLongerRun == true)
                {
                    output.Add(thisCombo);
                }
                else if (thisCombo.NumberInStraight > 0)
                {
                    hadStraight = HadProperStraight(thisCol, thisCombo);
                    if (hadStraight == true)
                    {
                        output.Add(thisCombo);
                    }
                }
                else if (thisCombo.NumberForKind > 2)
                {
                    hadKind = HadProperKind(thisCol, thisCombo);
                    if (hadKind == true)
                    {
                        output.Add(thisCombo);
                    }
                }
                else if (thisCombo.NumberForKind == 2)
                {
                    pairss = HowManyPairs(thisCol);
                    if (pairss > 0)
                    {
                        newCombo             = new CribbageCombos();
                        newCombo.Description = thisCombo.Description;
                        newCombo.Points      = pairss * thisCombo.Points;
                        output.Add(newCombo);
                    }
                }
                else
                {
                    throw new BasicBlankException("Combo Not Supported.  Rethink");
                }
            });
            if (output.Any(items => items.Points == 8))
            {
                if (output.Any(items => items.Points == 3 && items.NumberInStraight == 3))
                {
                    output.RemoveAllOnly(items => items.Points == 3 && items.NumberInStraight == 3); //because you got the double run of 3.
                }
            }
            return(output);
        }
        //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);
        }
示例#19
0
 public void UnlinkObjects()
 {
     _privateDict.ForEach(items => items.Reset());
 }
        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;
        }
示例#21
0
 public void CreateSet(IDeckDict <RegularRummyCard> thisList)
 {
     thisList.ForEach(thisCard => UpdateCard(thisCard));
     HandList.ReplaceRange(thisList);
 }