public bool IsFlush(IHand hand) { int currentPower = Convert.ToInt32(hand.Power); if (currentPower <= 5) { if (hand.CardsAreOfSameSuit()) { if (!hand.CardsAreFollowing(false)) { hand.SetPower(HandStrength.Flush); return true; } } } return false; }
public bool IsFourOfAKind(IHand hand) { int currentPower = Convert.ToInt32(hand.Power); if (currentPower <= 8) { if(hand.Cards[0].Face == hand.Cards[1].Face && hand.Cards[0].Face == hand.Cards[2].Face && hand.Cards[0].Face == hand.Cards[3].Face) { hand.SetPower(HandStrength.FourOfAKind); return true; } else if (hand.Cards[1].Face == hand.Cards[2].Face && hand.Cards[1].Face == hand.Cards[3].Face && hand.Cards[1].Face == hand.Cards[4].Face) { hand.SetPower(HandStrength.FourOfAKind); return true; } } return false; }
public bool IsTwoPair(IHand hand) { int currentPower = Convert.ToInt32(hand.Power); if (currentPower <= 3) { int cardCounter = 0; for (int i = 0; i < hand.Cards.Count - 1; i++) { if (hand.Cards[i].Face == hand.Cards[i + 1].Face) { cardCounter++; i++; if(cardCounter == 2) { hand.SetPower(HandStrength.TwoPair); return true; } } } } return false; }
public bool IsThreeOfAKind(IHand hand) { int currentPower = Convert.ToInt32(hand.Power); if (currentPower <= 4) { for (int i = 0; i < hand.Cards.Count - 2; i++) { bool isThreeOfAKind = false; int cardCounter = 0; for (int j = i + 1; j < hand.Cards.Count; j++) { if (hand.Cards[i].Face == hand.Cards[j].Face) { cardCounter++; if (cardCounter == 2) { isThreeOfAKind = true; } } } if (isThreeOfAKind) { hand.SetPower(HandStrength.ThreeOfAKind); return true; } } } return false; }
public bool IsStraight(IHand hand) { int currentPower = Convert.ToInt32(hand.Power); if (currentPower <= 6) { if (hand.CardsAreFollowing(false)) { hand.SetPower(HandStrength.Straight); return true; } } return false; }
public bool IsOnePair(IHand hand) { int currentPower = Convert.ToInt32(hand.Power); if (currentPower <= 2) { for (int i = 0; i < hand.Cards.Count; i++) { bool isOnePair = false; for (int j = i + 1; j < hand.Cards.Count; j++) { if (hand.Cards[i].Face == hand.Cards[j].Face) { isOnePair = true; } } if (isOnePair) { hand.SetPower(HandStrength.OnePair); return true; } } } return false; }
public bool IsHighCard(IHand hand) { int currentPower = Convert.ToInt32(hand.Power); if (currentPower <= 1) { hand.SetPower(HandStrength.HighCard); return true; } return false; }