private GamePot[] PlayersPots(TournamentPlayer player) { List <GamePot> playersPots = new List <GamePot>(); foreach (GamePot pot in pots) { if (pot.Has(player.UserId)) { playersPots.Add(pot); } } return(playersPots.ToArray()); }
/// <summary> /// Gets the player's bet total in the pots /// </summary> private int PlayerBet(TournamentPlayer player, bool ignoreLatestPot = false) { int sum = 0; foreach (GamePot pot in pots.Where(x => x.Has(player.UserId))) { if (ignoreLatestPot == false || pot != Pot) { sum += pot.Get(player.UserId).Funds; } } return(sum); }
private void SetNewBet(int newBet, TournamentPlayer player) { ResetChecks(); // Increase bet CurrentBet = newBet; if (CurrentBet > player.StartingFunds) { CurrentBet = player.StartingFunds; } Say("Veto nostettu => " + CurrentBet); }
/// <summary> /// Player is checked and the current bets set to their pots. /// </summary> private void CheckPlayer(TournamentPlayer player) { if (!player.Allin) { // Calculate the player's maximum available funds. int playerFunds = PlayerFunds(player); // Set the player's bets into previous pots first before processing the current pot. if (pots.Count > 1) { foreach (var pot in pots) { var playerPot = pot.Get(player.UserId); if (playerPot != null) { if (playerPot.Funds < pot.Max) { if (playerFunds < pot.Max) { // If the player cannot fully check into a previous sidepot, create a new sidepot. Player is now allin, and a part of the new sidepot. Pot.Get(player.UserId).Funds = playerFunds; NewSidePot(playerFunds, pot); player.Allin = true; Say(player.Username + " on Allin."); CheckAllins(); return; } else { // Set player's funds to the previous pot first and then recalculate their remaining funds before the next iteration. playerPot.Funds = pot.Max; playerFunds = PlayerFunds(player); } } } else { // If player doesn't have a bet in the current pot, add a new playerpot and recall CheckPlayer. pot.PlayerPots.Add(new PlayerPot(player.UserId, 0)); CheckPlayer(player); return; } } } // Get the player's current bet, ignoring the current pot playerFunds = PlayerBet(player, true); if (player.StartingFunds < CurrentBet) { Pot.Get(player.UserId).Funds = player.StartingFunds; NewSidePot(player.StartingFunds, Pot); player.Allin = true; Say(player.Username + " on Allin."); } else { if (player.StartingFunds == CurrentBet) { player.Allin = true; } Pot.Get(player.UserId).Funds = CurrentBet - playerFunds; player.Checked = true; } } CheckAllins(); }
/// <summary> /// Gets the total amount the player has placed into the pots /// </summary> private int PlayerFunds(TournamentPlayer player) { int totalBets = PlayerBet(player); return(player.StartingFunds - totalBets); }