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); }
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); }