/// <summary> /// Returns if the hand contains a Royal Flush /// </summary> /// <returns></returns> public bool HasRoyalFlush() { bool result = true; PokerCard pivotCard = Hand[0]; if (pivotCard.Value == PokerCard.ValueEnum.T) { for (int i = 1; result && i < Hand.Count; i++) { result = (pivotCard.Suit == Hand[i].Suit && pivotCard.Value + 1 == Hand[i].Value); pivotCard = Hand[i]; } } else { result = false; } if (result) { HighestCard = Hand.Last().Value; } return(result); }
/// <summary> /// Returns if the hand contains three of a kind /// </summary> /// <returns></returns> private bool HasThreeOfAKind() { bool result = true; int count = 1; const int three = 3; PokerCard pivotCard = Hand[0]; for (int i = 1; result && count < three && i < Hand.Count; i++) { result = (pivotCard.Suit != Hand[i].Suit && pivotCard.Value == Hand[i].Value); count++; } if (!result) { result = true; count = 1; pivotCard = Hand[1]; for (int i = 2; result && count < three && i < Hand.Count; i++) { result = (pivotCard.Suit != Hand[i].Suit && pivotCard.Value == Hand[i].Value); count++; } } if (!result) { result = true; count = 1; pivotCard = Hand[2]; for (int i = 3; result && count < three && i < Hand.Count; i++) { result = (pivotCard.Suit != Hand[i].Suit && pivotCard.Value == Hand[i].Value); count++; } } if (result) { HighestCard = pivotCard.Value; } return(result); }
/// <summary> /// Returns if the hand contains a Flush /// </summary> /// <returns></returns> private bool HasFlush() { bool result = false; int count = (from c in Hand where c.Suit == Hand[0].Suit select c.Suit).Count(); result = (count == 5); if (result) { HighestCard = Hand[4].Value; } return(result); }
/// <summary> /// Returns if the hand contains a Full House /// </summary> /// <returns></returns> private bool HasFullHouse() { bool result = false; if ((Hand[0].Value == Hand[1].Value && Hand[0].Value == Hand[2].Value) && Hand[3].Value == Hand[4].Value) { result = true; HighestCard = Hand[0].Value; SecondHighestCard = Hand[3].Value; } if ((Hand[2].Value == Hand[3].Value && Hand[2].Value == Hand[4].Value) && Hand[0].Value == Hand[1].Value) { result = true; HighestCard = Hand[2].Value; SecondHighestCard = Hand[0].Value; } return(result); }