Exemple #1
0
        ///// PLAYER BETTING /////

        public void preFlopBetting(Pot pot)
        {
            this.street = Street.PREFLOP;
            Seat ss = this.fp;

            this.bettingRound(ss, pot);
        }
Exemple #2
0
        public void awardPot(Pot pot)
        {
            List <Player> players = table.getPlayersToAnalyze();

            if (players.Count == 1)
            {
                players.First().addToStack(pot.PotSize);
            }
        }
Exemple #3
0
 public List <Player> postAnte(List <Player> activePlayers, Pot pot)
 {
     foreach (Player p in activePlayers)
     {
         BetResponse res = p.removeFromStack(this.ante);
         if (res.complete)
         {
             Action a = new PostAnte(p, res.amount);
             pot.handleAction(a);
         }
         else
         {
             activePlayers.Remove(p);
         }
     }
     return(activePlayers);
 }
Exemple #4
0
        public List <Player> postSB(List <Player> activePlayers, Pot pot)
        {
            Player      sb  = this.sb.player;
            BetResponse res = sb.removeFromStack(this.smallBlind);

            if (res.complete)
            {
                Action a = new PostSB(sb, res.amount);
                pot.handleAction(a);
            }
            else
            {
                activePlayers.Remove(sb);
                this.rotatePlayers();
                return(this.postSB(activePlayers, pot));
            }
            return(activePlayers);
        }
Exemple #5
0
        public void handleEndgame(Board b, Pot pot)
        {
            List <Player>      players = table.getPlayersToAnalyze();
            List <PreflopHand> hands   = players.Select(p => p.Hand).ToList();

            WinState ws       = PickWinner.determineWinner(b, hands);
            double   potShare = pot.PotSize * ws.equity;

            foreach (Player p in players)
            {
                foreach (BestHand bh in ws.winningHands)
                {
                    if (bh.hasBestHand(p.Hand, b))
                    {
                        p.addToStack(potShare);
                    }
                }
            }
        }
Exemple #6
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);
            }
        }
Exemple #7
0
        ///// POSTING BLINDS /////

        public List <Player> postBB(List <Player> activePlayers, Pot pot)
        {
            Player      bb  = this.bb.player;
            BetResponse res = bb.removeFromStack(this.bigBlind);

            if (res.complete)
            {
                Action a = new PostBB(bb, res.amount);
                pot.handleAction(a);
            }
            else
            {
                activePlayers.Remove(bb);
                this.bb = table.getNearestLeftSeatWithActivePlayer(this.bb);
                this.fp = table.getNearestLeftSeatWithActivePlayer(this.fp);
                return(this.postBB(activePlayers, pot));
            }
            return(activePlayers);
        }
Exemple #8
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);
            }
        }
Exemple #9
0
        public void postFlopBetting(Pot pot)
        {
            Seat ss = this.sb.player.isInHand() ? this.sb : table.getNearestLeftSeatInHand(this.sb);

            this.bettingRound(ss, pot);
        }
Exemple #10
0
        // logic during an entire poker hand
        // SOLVED BUG --> must 'return' after 'awardPot' call
        public async Task startRound()
        {
            this.deck = new Deck(new HashSet <Card>()); // reset 'deck' for new round
            Pot       = new Pot(this.bigBlind);         // reset Pot for new round
            Board     = null;                           // reset Board for new round
            Street    = Street.PREFLOP;

            this.pot.registerActivePlayersByStreet(this.activePlayers, this.street);

            if (this.ante > 0)
            {
                this.activePlayers = this.postAnte(this.activePlayers, this.pot);
            }
            this.activePlayers = this.postSB(activePlayers, this.pot);
            this.activePlayers = this.postBB(activePlayers, this.pot);

            if (!this.areReady(this.activePlayers))
            {
                Status = GameStatus.WAITING;
                return;
            }

            this.generateHands(this.activePlayers);
            this.clientPlayer.showHand();
            await this.preFlopBetting(this.pot);

            if (this.activePlayers.Count < 2)
            {
                this.awardPot(this.pot);
                return;
            }

            Board  = this.generateFlop(this.deck);
            Street = Street.FLOP;
            this.pot.registerActivePlayersByStreet(this.activePlayers, this.street);
            await this.postFlopBetting(this.pot);

            if (this.activePlayers.Count < 2)
            {
                this.awardPot(this.pot);
                return;
            }

            Board  = this.generateTurn(this.deck, this.board);
            Street = Street.TURN;
            this.pot.registerActivePlayersByStreet(this.activePlayers, this.street);
            await this.postFlopBetting(this.pot);

            if (this.activePlayers.Count < 2)
            {
                this.awardPot(this.pot);
                return;
            }

            Board  = this.generateRiver(this.deck, this.board);
            Street = Street.RIVER;
            this.pot.registerActivePlayersByStreet(this.activePlayers, this.street);
            await this.postFlopBetting(this.pot);

            this.handleEndgame(this.board, this.pot);
        }
Exemple #11
0
        ///// PLAYER BETTING /////

        public async Task preFlopBetting(Pot pot)
        {
            Seat ss = this.fp;

            await this.bettingRound(ss, pot);
        }