}//check for stright public CardConstants.HandRank MaxRankeInTable()//Hand val like royal flush ,one pair etc.... { CardConstants.HandRank MaxHand = CardConstants.HandRank.none; foreach (texasPlayer p in players) { if (p.PlayerHandRank > MaxHand && p.playerState != texasPlayer.PlayerState.fold) { MaxHand = p.PlayerHandRank; } } return(MaxHand); }//return the max hand Rank in the table
public void ShowDown() { ServerEnterGameState(CardConstants.GameTurnState.Complete, "Show Down", MainPot); foreach (texasPlayer player in players) { if (player.playerState == texasPlayer.PlayerState.fold) { continue; } else { List <CardId> finalhand = new List <CardId>(); foreach (CardId card in player.handCards) { finalhand.Add(card); } foreach (CardId card in cardsInTable) { finalhand.Add(card); } player.PlayerHandRank = EvaluatPlayerHand(finalhand); player.totalHandValue = HandAnalizer.TotalValue; } } List <texasPlayer> tmpwinners = new List <texasPlayer>(); List <texasPlayer> Winners = new List <texasPlayer>(); CardConstants.HandRank winningHand = MaxRankeInTable(); //Hand Val Max int maximunHandscore = MaxTotalValue(); //Max total value in numbers foreach (texasPlayer p in players) { if (p.PlayerHandRank == winningHand && p.playerState != texasPlayer.PlayerState.fold) { tmpwinners.Add(p); } } if (tmpwinners.Count > 1) { foreach (texasPlayer p in tmpwinners) { if (p.totalHandValue == maximunHandscore) { Winners.Add(p); } } int numWinners = Winners.Count; foreach (texasPlayer p in Winners) { p.ServerPayout((int)MainPot / Winners.Count); Debug.Log("" + " " + Winners.Count); } foreach (texasPlayer player in players) { if (!Winners.Contains(player)) { player.ServerLose(player.tmpBet); } } } else { tmpwinners[0].ServerPayout((int)MainPot); foreach (texasPlayer player in players) { if (tmpwinners[0] != player) { player.ServerLose(player.tmpBet); } } } ServerNextState("ServerNextHand"); }//Show down funtion declear the winner after evaluating ever hand in the table and comparison of the player one against the other at the end start game again