/// <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); }
public void StartRound() { if (GameState != RoboGameState.Ready) { return; } OnGameStateChange(EventArgs <RoboGameState> .create(RoboGameState.DrawingCards)); foreach (RoboPlayerPlugin elem in ActivePlayers) { if (elem.Player.PlayerState != RoboPlayerState.Ready) { continue; } if (!elem.Player.StartRound()) { elem.Player.PlayerState = RoboPlayerState.Dead; continue; } (elem.PluginSettings as RoboPlayerPluginSettings).PlayerCollision = Interaction == RoboPlayerInteraction.Blocked; Action <RoboPosition, ICollection <RoboCard>, IEnumerable <RoboPosition> > pluginCaller = elem.StartRound; pluginCaller.BeginInvoke( elem.Player.Position.Clone() as RoboPosition, elem.Player.Cards, ActivePlayers.Select(plugin => plugin.Player.Position.Clone() as RoboPosition), null, elem); elem.Player.PlayerState = RoboPlayerState.Thinking; } OnGameStateChange(EventArgs <RoboGameState> .create(RoboGameState.ChoosingCards)); if (ActivePlayers.Count(elem => elem.Player.PlayerState == RoboPlayerState.Thinking) == 0) { OnGameStateChange(EventArgs <RoboGameState> .create(RoboGameState.Stopped)); } }
public void DoAction(PokerPlayer player, PlayerAction action, int bet = 0, bool isforced = false, bool verbose = true) { if (!isforced && CurrentTurn != player) { return; } var pm = player.Owner; string message = string.Empty; Exporter.AddAction(pm, action, State, action == PlayerAction.AllIn ? player.Currency : bet); switch (action) { case PlayerAction.Bet: message = String.Format("I {0} {1}.", "bet", bet); MakeBet(player, bet); MinimumBet = bet; //raise after a bet is always 2*bet according to poker rules MinimumRaise = bet * 2; break; case PlayerAction.Raise: message = String.Format("I {0} {1}.", RoundActions.Exists(x => x == PlayerAction.Raise) ? "reraise" : "raise", bet); MakeBet(player, GetCallAmount(player) + bet); MinimumBet += bet; MinimumRaise = bet; break; case PlayerAction.Call: message = "I call."; //match what is on the table from the last player. This takes into account how much you already have on the table in that round bet = GetCallAmount(player); MakeBet(player, bet); break; case PlayerAction.Check: message = "Check."; break; case PlayerAction.Fold: message = "I fold."; player.HasFolded = true; if (ActivePlayers.Count(x => !x.HasFolded) == 1) { DoShowdown(); return; } break; case PlayerAction.AllIn: if (player.Currency > 0) { message = MinimumBet > player.Currency ? "I call: all-in." : "All in."; int difference = player.Currency + player.TotalBetInRound; if (difference > MinimumBet) { MinimumBet = difference; } MakeBet(player, player.Currency); } break; } RefreshGumps(); if (verbose) { PokerMessage(pm, message); } if (!isforced) { player.HasActed = true; } RoundActions.Add(action); if (!isforced && !CanEndBettingRound()) { AssignNextTurn(); } }
/// <summary> /// Get a count of all players in a game that can still act in rounds /// </summary> public int GetActiveElliblePlayersCount() { return(ActivePlayers.Count(x => x.Currency > 0 && !x.HasFolded)); }