private void TraversePlayers(int index) { while (!EndOfBettingRound()) { Console.WriteLine(index); PlayingUser currentUser = players.ElementAt(index); int minimumBet = GetMaxBet() - playerBets[currentUser]; if (!(currentUser.GetStatus().Equals("Fold") && (currentUser.GetStatus().Equals("Quit")))) //player didn't fold { int bet = players[index].Bet(minimumBet); while (bet < minimumBet && bet >= 0) { bet = currentUser.BadBet(bet, minimumBet); } if (bet >= 0) //check|call|raise { playerBets[currentUser] += bet; bettingRound += bet; PushBetMove(currentUser, bet); } else //fold { playerBets[currentUser] = 0; playerHands.Remove(currentUser.GetUserName());//username currentUser.SetStatus("Fold"); PushFoldMove(currentUser); } if (DidEveryoneFold()) { pot[0] += bettingRound; bettingRound = 0; gameEnded = true; return; } } index++; if (index == players.Count) { index = 0; } } pot[0] += bettingRound; bettingRound = 0; foreach (PlayingUser player in players) { if (player.GetStatus() == "Talked") { player.SetStatus("Active"); } } }
public void removePlayer(PlayingUser player) { if (players.Count == 0) { throw new InvalidOperationException("No players to remove"); } if (!players.Contains(player)) { throw new InvalidOperationException("Player not in game"); } if (this.gamePref.GetStatus().Equals("Inactive") || this.gamePref.GetStatus().Equals("Init")) //not in middle of round { players.Remove(player); playerBets.Remove(player); } else //in middle of round { if (playerHands.ContainsKey(player.GetUserName())) { playerHands.Remove(player.GetUserName()); //remove this now so that their hand isn't calculated in CA } player.SetStatus("Quit"); } var e = evt; if (e != null) { evt(player); } player = null; }