public static List <PokerPlayer> DetermineWinner(List <PokerPlayer> activePlayers) { List <PokerPlayer> winners = new List <PokerPlayer>(); winners.Add(activePlayers[0]); HandRank bestHand = activePlayers[0].GetHandRank(); for (int i = 1; i < activePlayers.Count; ++i) { HandRank hand = activePlayers[i].GetHandRank(); int result = hand.CompareTo(bestHand); if (result == 1) { bestHand = hand; winners.Clear(); winners.Add(activePlayers[i]); } else if (result == 0) { winners.Add(activePlayers[i]); } } return(winners); }
public void HandRank_CompareTo_RankIsGreater() { var test = new HandRank(HandRankEnum.RoyalFlush); var test2 = new HandRank(HandRankEnum.StraighFlush); Assert.AreEqual(1, test.CompareTo(test2)); Assert.AreEqual(-1, test2.CompareTo(test)); }
public override int CompareToOffsuitHand(OffsuitHandBase other) { var otherStraight = other as Straight; if (otherStraight == null) { return(HandRank.CompareTo(other.HandRank)); } return(TopCardRank.CompareTo(otherStraight.TopCardRank)); }
public override int CompareToOffsuitHand(OffsuitHandBase other) { var otherFourSome = other as FourSome; if (otherFourSome == null) { return(HandRank.CompareTo(other.HandRank)); } return(Kicker.CompareTo(otherFourSome.Kicker)); }
public override int CompareToSuitedHand(SuitedHandBase other) { var otherStraightFlush = other as StraightFlush; if (otherStraightFlush == null) { return(HandRank.CompareTo(other.HandRank)); } return(TopRank.CompareTo(otherStraightFlush.TopRank)); }
public void HandRank_CompareTo_HighCardIsGreater() { var test = new HandRank(HandRankEnum.Flush) { RankHighCardValue = 8, RankSecondHighCardValue = 7, HighCardValue = 5 }; var test2 = new HandRank(HandRankEnum.Flush) { RankHighCardValue = 8, RankSecondHighCardValue = 7, HighCardValue = 3 }; Assert.AreEqual(1, test.CompareTo(test2)); Assert.AreEqual(-1, test2.CompareTo(test)); }
public void HandRank_CompareTo_RankHighCardIsGreater() { var test = new HandRank(HandRankEnum.StraighFlush) { RankHighCardValue = 8 }; var test2 = new HandRank(HandRankEnum.StraighFlush) { RankHighCardValue = 7 }; Assert.AreEqual(1, test.CompareTo(test2)); Assert.AreEqual(-1, test2.CompareTo(test)); }
public override int CompareToOffsuitHand(OffsuitHandBase other) { var otherFullHouse = other as FullHouse; if (otherFullHouse == null) { return(HandRank.CompareTo(other.HandRank)); } if (TriRank != otherFullHouse.TriRank) { return(TriRank.CompareTo(otherFullHouse.TriRank)); } return(PairRank.CompareTo(otherFullHouse.PairRank)); }
public override int CompareToOffsuitHand(OffsuitHandBase other) { var otherThreeSome = other as ThreeSome; if (otherThreeSome == null) { return(HandRank.CompareTo(other.HandRank)); } if (TriRank != otherThreeSome.TriRank) { return(TriRank.CompareTo(otherThreeSome.TriRank)); } if (Kicker1Rank != otherThreeSome.Kicker1Rank) { return(Kicker1Rank.CompareTo(otherThreeSome.Kicker1Rank)); } return(Kicker2Rank.CompareTo(otherThreeSome.Kicker2Rank)); }
public override int CompareToOffsuitHand(OffsuitHandBase other) { var otherTwoPairs = other as TwoPairs; if (otherTwoPairs == null) { return(HandRank.CompareTo(other.HandRank)); } if (Pair1Rank != otherTwoPairs.Pair1Rank) { return(Pair1Rank.CompareTo(otherTwoPairs.Pair1Rank)); } if (Pair2Rank != otherTwoPairs.Pair2Rank) { return(Pair2Rank.CompareTo(otherTwoPairs.Pair2Rank)); } return(KickerRank.CompareTo(otherTwoPairs.KickerRank)); }
public void HandRank_CompareTo_HighCardsAreGreater_DueToLongerList() { var test = new HandRank(HandRankEnum.HighCard) { RankHighCardValue = 8, RankSecondHighCardValue = 7, HighCardValue = 5 }; var test2 = new HandRank(HandRankEnum.HighCard) { RankHighCardValue = 8, RankSecondHighCardValue = 7, HighCardValue = 5 }; test.SetHighCardValues(new List <int> { 9, 10, 7 }); test2.SetHighCardValues(new List <int> { 9, 6, 10, 7 }); Assert.AreEqual(1, test.CompareTo(test2)); Assert.AreEqual(-1, test2.CompareTo(test)); }
public void HandRank_CompareTo_AreEqual() { var test = new HandRank(HandRankEnum.HighCard) { RankHighCardValue = 8, RankSecondHighCardValue = 7, HighCardValue = 5 }; var test2 = new HandRank(HandRankEnum.HighCard) { RankHighCardValue = 8, RankSecondHighCardValue = 7, HighCardValue = 5 }; test.SetHighCardValues(new List <int> { 9, 10, 7, 6, 4 }); test2.SetHighCardValues(new List <int> { 9, 6, 10, 4, 7 }); Assert.AreEqual(0, test.CompareTo(test2)); Assert.AreEqual(0, test2.CompareTo(test)); }