/// <summary> /// Check if only one player is left that isn't allin. /// </summary> private void CheckAllins() { if (ActivePlayers.Count(x => x.Allin) == ActivePlayers.Length - 1 && ActivePlayers.First(x => !x.Allin).Checked) { foreach (var player2 in ActivePlayers) { player2.Allin = true; } } else { CurrentPlayerIndex = NextActivePlayerIndex(CurrentPlayerIndex); } // If only one player isn't allin, check everyone as allin. No further actions can be taken. //if (ActivePlayers.Where(x => !x.Allin && x.Checked).Count() <= 1) //{ // foreach (var player2 in ActivePlayers) // { // player2.Allin = true; // } //} //else //{ // CurrentPlayerIndex = NextActivePlayerIndex(CurrentPlayerIndex); //} }
public bool Fold(Msg message) { if (ValidPlayer(message.From)) { var player = Players.FirstOrDefault(x => x.UserId == message.From.UserId); if (player.Active && !player.Allin && !player.Checked) { player.Active = false; Bot.Say(player.Username, "Foldaat."); if (ActivePlayers.Count(x => x.Allin) == ActivePlayers.Length - 1 && ActivePlayers.First(x => !x.Allin).Checked) { foreach (var player2 in ActivePlayers) { player2.Allin = true; } } } if (!CheckStatuses()) { CurrentPlayerIndex = NextActivePlayerIndex(CurrentPlayerIndex); } return(true); } else { NotAPlayer(message.From.Username); } return(false); }