private int FindBestCard(DeckRegularDict <RegularSimpleCard> list) { var bestsuit = list.GroupBy(x => x.Suit).OrderByDescending(Temps => Temps.Count()); var suituse = bestsuit.First().Key; list.KeepConditionalItems(Items => Items.Suit == suituse); return(list.GetRandomItem().Deck); }
public bool IsSuit(DeckRegularDict <MonasteryCardInfo> thisCol, int required) { if (thisCol.Count < required) { return(false); } return(thisCol.GroupBy(items => items.Suit).Count() == 1); }
public bool IsKind(DeckRegularDict <MonasteryCardInfo> thisCol, bool needColor, int required) { if (thisCol.Count < required) { return(false); } if (needColor) { if (thisCol.GroupBy(items => items.Color).Count() > 1) { return(false); } } var tempCol = PopulateTempCol(thisCol, out DeckRegularDict <MonasteryCardInfo> aceList); if (tempCol.Count == 0) { return(true); } return(tempCol.GroupBy(items => items.Value).Count() == 1); }
public bool IsRun(DeckRegularDict <MonasteryCardInfo> thisCol, EnumRunType needType, int required) { if (thisCol.Count < required) { return(false); } if (needType == EnumRunType.Suit) { if (thisCol.GroupBy(items => items.Suit).Count() > 1) { return(false); } } if (needType == EnumRunType.Color) { if (thisCol.GroupBy(items => items.Color).Count() > 1) { return(false); } } var tempCol = PopulateTempCol(thisCol, out DeckRegularDict <MonasteryCardInfo> aceList); if (tempCol.Count == 0) { return(true); //if all aces, then fine at this point. } int howMany = tempCol.GroupBy(items => items.Value).Count(); if (howMany != tempCol.Count) { return(false); } int currentNumber = 0; int diffs; int previousNumber = 0; int x = 0; foreach (var thisCard in tempCol) { x++; currentNumber = (int)thisCard.Value; if (x == 1) { previousNumber = (int)thisCard.Value; } else { diffs = currentNumber - previousNumber - 1; if (diffs > 0) { if (aceList.Count < diffs) { return(false); } diffs.Times(y => aceList.RemoveFirstItem()); } } previousNumber = (int)thisCard.Value; } return(true); }
public bool IsFlush() { return(CardList.GroupBy(items => items.Suit).Count() == 1); }