Exemplo n.º 1
0
 // used to determine which actions are available for player/bot
 public void populateActions(PotState state)
 {
     IsFoldAvailable  = state.currentBet != state.playerContribution;
     IsCheckAvailable = state.currentBet == state.playerContribution;
     IsCallAvailable  = state.currentBet > state.playerContribution;
     IsRaiseAvailable = state.currentBet >= state.playerContribution;
 }
Exemplo n.º 2
0
        private bool canRaise(object e)
        {
            if (!isRaiseAvailable)
            {
                return(false);
            }
            if (awaitingActionArgs == null)
            {
                return(false);
            }

            PotState ps = awaitingActionArgs.potState;

            double low  = ps.minRaise < stack ? ps.minRaise : stack;
            double high = ps.maxBet < stack ? ps.maxBet : stack;

            return(BetAmount >= low && BetAmount <= high);
        }
Exemplo n.º 3
0
        public void bettingRound(Seat startingSeat, Pot pot)
        {
            while (true)
            {
                Player p = startingSeat.player;

                GameState gs = this.getState();
                PotState  ps = pot.getState(p, this.street);

                if (pot.hasActed(p, this.street) && ps.playerContribution == ps.currentBet)
                {
                    break;
                }

                //Action a = p.selectAction(gs, ps);
                //pot.handleAction(a);
                startingSeat = table.getNearestLeftSeatInHand(startingSeat);
            }
        }
Exemplo n.º 4
0
        // logic for a single street of betting during a poker hand
        public async Task bettingRound(Seat startingSeat, Pot pot)
        {
            while (true)
            {
                Player p = startingSeat.player;
                this.ActivePlayer   = p;
                this.TurnTimer      = 30;
                this.turnInProgress = true;

                GameState gs = this.getState();
                PotState  ps = pot.getState(p, this.street);

                // used to end betting round if not enough players to continue (due to folding/etc)
                if (this.activePlayers.Count < 2)
                {
                    break;
                }

                // used to end the betting round if all players have acted (and action is completed)
                // BUG --> RRR (line will end the round on the 3rd Raise with 2 players)
                // probably buggy in general
                if (pot.hasActed(p, this.street) && ps.playerContribution == ps.currentBet)
                {
                    break;
                }

                // raises Action and waits for response, WORKING
                OnPlayerTurn(new AwaitingActionEventArgs(gs, ps, p));

                while (turnInProgress)
                {
                    await this.DecrementTimer();
                }

                // updates list of InHand players based on most recent Action
                this.activePlayers = this.table.getInHandPlayers();

                // moves ActivePlayer to the next available Player
                startingSeat = table.getNearestLeftSeatInHand(startingSeat);
            }
        }
Exemplo n.º 5
0
        /* AwaitingPlayerAction handler */

        /* updates Player state to allow Player to make an Action
         * render UI
         * set MinRaise/ToCall/CurrentContribution/etc
         *
         */
        public void AwaitPlayerAction(object sender, AwaitingActionEventArgs e)
        {
            if (e.player != this)
            {
                return;
            }                                 // escapes events that are not targeted at this Player

            this.IsAwaitingAction   = true;
            this.awaitingActionArgs = e;

            PotState ps = e.potState;

            this.populateActions(ps); // sets available Commands

            // WORKING
            MinRaise  = ps.minRaise;
            ToCall    = ps.toCall;
            BetAmount = ps.minRaise;

            // used to immediately update 'canCheck/canRaise'
            CommandManager.InvalidateRequerySuggested();
        }
Exemplo n.º 6
0
        }                                      // updated PotState

        public AwaitingActionEventArgs(GameState gs, PotState ps, Player p)
        {
            this.player    = p;
            this.gameState = gs;
            this.potState  = ps;
        }