public static void FindFields() { //first we need to initialize all the attributes in the class InitializeAttr(); //find the players (and all the other texts) in the table int i = 0; while (i < 3) { PlayerNames.Add(GameObject.Find(string.Concat("Player", (i + 1))).GetComponent <Text>()); PlayersCoins.Add(GameObject.Find(string.Concat("Player", (i + 1), "Coins")).GetComponent <Text>()); PlayersBets.Add(GameObject.Find(string.Concat("Player", (i + 1), "Bet")).GetComponent <Text>()); PlayersHandCount.Add(GameObject.Find(string.Concat("Player", (i + 1), "Hand")).GetComponent <Text>()); PlayersBlackjackBet.Add(GameObject.Find(string.Concat("Player", (i + 1), "Blackjack")).GetComponent <Text>()); PlayersCardsPositions.Add(GameObject.Find(string.Concat("cardFieldPlayer", (i + 1)))); i++; } //find the cards positions for the dealer DealerPositions.Add(GameObject.Find("DealerFieldCard1").GetComponent <Transform>()); DealerPositions.Add(GameObject.Find("DealerFieldCard2").GetComponent <Transform>()); DealerLastCardPosition = GameObject.Find("DealerFieldCard2").GetComponent <Transform>(); //set the last card position of all the player foreach (GameObject tmpObjectPosition in PlayersCardsPositions) { PlayersLastCardPosition.Add(tmpObjectPosition.transform.GetChild(1)); } }
private void PickAWinner() { //Change all player's bets to negative numbers (for statistics) foreach (Player player in activePlayers) { PlayersBets[player] *= -1; } //Go to the last pot Pot lastPot = CurrentRound.CurrentPot; while (lastPot.BasePot != null) { lastPot = lastPot.BasePot; } List <Player> potWinners; //pick winner for each pot separately while (lastPot != null) { PickAWinner pickPotWinner = new PickAWinner(lastPot.PlayersClaimPot, communityCards); potWinners = pickPotWinner.GetWinners(); double playerWinningMoney = lastPot.Value / potWinners.Count; //divide pot money to winning players foreach (Player player in potWinners) { if (!PlayersBets.ContainsKey(player)) { throw new PlayerNotFoundException("Can't find the winning player in the acitveUnfoldedPlayers... not possible"); } PlayersBets[player] += playerWinningMoney; player.AddMoney(playerWinningMoney); } lastPot = lastPot.PartialPot; } }