public static bool DidPlayerOneWin(string onehand) { var playerOneHands = new Hands(onehand.Substring(0, 15)); var playerTwoHands = new Hands(onehand.Substring(15, 14)); var playerOneHandRank = playerOneHands.HandRank(); var playerTwoHandRank = playerTwoHands.HandRank(); if (playerOneHandRank > playerTwoHandRank) { return(true); } if (playerOneHandRank < playerTwoHandRank) { return(false); } if (playerOneHandRank == 9 || playerOneHandRank == 6 || playerOneHandRank == 5 || playerOneHandRank == 1) { return(Hands.HighestRank(playerOneHands.hands.OrderByDescending(hand => hand.CardNumber).ToList(), playerTwoHands.hands.OrderByDescending(hand => hand.CardNumber).ToList())); } if (playerOneHandRank == 8) { return(Hands.HighestRank(playerOneHands.FourOfAKind(), playerTwoHands.FourOfAKind())); } if (playerOneHandRank == 7 || playerOneHandRank == 4) { return(Hands.HighestRank(playerOneHands.ThreeOfAKind(), playerTwoHands.ThreeOfAKind())); } if (playerOneHandRank == 2 || playerOneHandRank == 3) { return(Hands.HighestRank(playerOneHands.NumberOfPairs(), playerTwoHands.NumberOfPairs())); } return(false); }
public static bool DidPlayerOneWin(string onehand) { var playerOneHands = new Hands(onehand.Substring(0,15)); var playerTwoHands = new Hands(onehand.Substring(15,14)); var playerOneHandRank = playerOneHands.HandRank(); var playerTwoHandRank = playerTwoHands.HandRank(); if (playerOneHandRank > playerTwoHandRank) return true; if (playerOneHandRank < playerTwoHandRank) return false; if(playerOneHandRank == 9 || playerOneHandRank == 6 || playerOneHandRank == 5 || playerOneHandRank == 1) { return Hands.HighestRank(playerOneHands.hands.OrderByDescending(hand => hand.CardNumber).ToList(), playerTwoHands.hands.OrderByDescending(hand => hand.CardNumber).ToList()); } if(playerOneHandRank == 8) { return Hands.HighestRank(playerOneHands.FourOfAKind(), playerTwoHands.FourOfAKind()); } if(playerOneHandRank == 7 || playerOneHandRank == 4 ) { return Hands.HighestRank(playerOneHands.ThreeOfAKind(), playerTwoHands.ThreeOfAKind()); } if(playerOneHandRank == 2 || playerOneHandRank == 3) { return Hands.HighestRank(playerOneHands.NumberOfPairs(), playerTwoHands.NumberOfPairs()); } return false; }