public static HandPlayResult TestHandChances(PokerHand hand, OrderedCardSet handCards, ICardDealer dealer) { OrderedCardSet oponentSet = HoldemHand.GetOtherCards(dealer.FullDeck, handCards, dealer.CommunityCards); int wins = 0, ties = 0, losses = 0; List <OrderedCardSet> allHands = GetOpponentCombinationOfHandCards(oponentSet); foreach (OrderedCardSet iHand in allHands) { PokerHand otherHand = HoldemHand.ChooseBestHand(iHand, dealer.CommunityCards); int compare = hand.CompareTo(otherHand); if (compare > 0) { wins += 1; } else if (compare < 0) { losses += 1; } else { ties += 1; } } return(new HandPlayResult(allHands.Count, wins, ties, losses)); }
public void setupGame() { GameTurns += 1; stage = GameStage.SETUP; if (HumanPlayer.Money <= 0 || RoboPlayer.Money <= 0) { //Should not be needed since winner of the last round does not lose money /* if (RoboPlayer.Money < 0) * { * Winner = WinStatus.PLAYER_HUMAN; * } * else if (HumanPlayer.Money < 0) * { * Winner = WinStatus.PLAYER_ROBO; * }*/ endGame(); return; } else { Pot = 20; HumanPlayer.Money -= 10; RoboPlayer.Money -= 10; HumanPlayer.Hand = null; RoboPlayer.Hand = null; GameDealer.ShuffleAndDealDeck(HumanPlayer, RoboPlayer); HumanPlayer.Hand = HoldemHand.ChooseBestHand(HumanPlayer.HandCards, GameDealer.CommunityCards); RoboPlayer.Hand = HoldemHand.ChooseBestHand(RoboPlayer.HandCards, GameDealer.CommunityCards); HumanPlayer.HandChances = HoldemHand.TestHandChances(HumanPlayer.Hand, HumanPlayer.HandCards, GameDealer); RoboPlayer.HandChances = HoldemHand.TestHandChances(RoboPlayer.Hand, RoboPlayer.HandCards, GameDealer); } if (GameListener != null) { GameListener.PostGameSetup(); } sendPlayerTurn(); }