示例#1
0
 public bool HasRaised()
 {
     return(RoundActions.Exists(x => x == PlayerAction.Raise));
 }
示例#2
0
        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();
            }
        }
示例#3
0
 /// <summary>
 ///     Raises can only be made if a bet has already been posted
 ///     <returns>amount needed to meet call</returns>
 /// </summary>
 public bool CanRaise()
 {
     return(RoundActions.Exists(x => x == PlayerAction.Bet));
 }