public void endHand(GameState state) { MessageBox.Show("Hand over."); List<Player> playersLeftInGame = new List<Player>(); List<Player> playersLeftInHand = new List<Player>(); foreach (Player player in state.players) if (player.inHand && player.chipsCommitted > 0 ) // player.chipsCommitted to exclude people who went allin earlier playersLeftInHand.Add(player); state.endTurn(); decideWinnersAndPayChips(new Tuple<int, List<Player>>(state.potCount, playersLeftInHand)); foreach (Tuple<int, List<Player>> sidePot in state.sidePots) decideWinnersAndPayChips(sidePot); foreach (Player player in state.players) if (player.chipCount != 0) playersLeftInGame.Add(player); else { RulesAndMethods.AddToLog("Player " + player.name + " was eliminated."); player.inHand = false; player.clearCards(); // gets rid of cards for people who are eliminated } state.players = playersLeftInGame; foreach (Player player in state.players) player.clearCards(); // gets rid of cards of players still alive if (state.players.Count > 1 && state.humanIsAlive()) { // sets next buttonPos state.buttonPos++; state.buttonPos = state.buttonPos % state.players.Count; state.clearPublicCards(); newHand(state); } else { state.gameOver = true; if(!currentHumanPlayer.outOfMoney()) state.players[0].inHand = false; // so if human wins doesn't try to display cards MessageBox.Show("GAME OVER."); } }