예제 #1
0
 public void updateGame(Move moveChoice, Player currentActor)
 {
     if (moveChoice is Fold)
     {
         currentActor.folded = true;
         activePlayers.Remove(currentActor);
         this.game.playerFolded(currentActor.position);
     }
     else if (moveChoice is Check)
     {
         this.game.playerChecked(currentActor.position);
     }
     else if (moveChoice is Call)
     {
         this.potValue = this.potValue + moveChoice.amountPotRaised;
         this.game.playerCalled(currentActor.position, this.potValue, currentActor.currentStack);
         if (currentActor.currentStack == 0)
         {
             activePlayers.Remove(currentActor);
         }
     }
     else if (moveChoice is Raise)
     {
         this.potValue = this.potValue + moveChoice.amountPotRaised;
         this.currentBet = this.currentBet + moveChoice.currentBetRaised;
         this.game.playerRaised(currentActor.position, this.potValue, currentActor.currentStack, moveChoice.currentBetRaised);
     }
 }
예제 #2
0
 private void submitButton_Click(object sender, RoutedEventArgs e)
 {
     this.moveChoice = (Move) moveChoiceComboBox.SelectedItem;
     this.moveChosen = true;
     this.DialogResult = true;
 }
예제 #3
0
        public override void handleBettingSession()
        {
            resetBetInRounds();

            //do preflop bets
            activePlayers[0].currentStack = activePlayers[0].currentStack - 10;
            activePlayers[0].betInRound   = 10;
            updateGame(new Raise(10, 10), activePlayers[0]);
            activePlayers[1].currentStack = activePlayers[1].currentStack - 20;
            activePlayers[1].betInRound   = 20;
            updateGame(new Raise(20, 10), activePlayers[1]);


            //create player queue but put the first two players at the bottom because they did the blinds
            PlayerQueue playersInSession = new PlayerQueue();

            for (int i = 2; i < activePlayers.Count; i++)
            {
                playersInSession.addPlayer(activePlayers[i]);
            }
            playersInSession.addPlayer(activePlayers[0]);
            playersInSession.addPlayer(activePlayers[1]);

            Player firstPlayerWithNoChoice = null;
            bool   isFirstPlayersTurn      = true;
            bool   isSessionOver           = false;

            while (!isSessionOver && (playersInSession.getCount() > 1))
            {
                Player currentActor = playersInSession.getCurrentPlayer();
                if (currentActor == firstPlayerWithNoChoice)
                {
                    isSessionOver = true;
                    break;
                }
                Move moveChoice = currentActor.makeMove(this);
                updateGame(moveChoice, currentActor);
                if (moveChoice is Fold)
                {
                    playersInSession.removeCurrentPlayer();
                }
                else if (moveChoice is Check)
                {
                    playersInSession.advanceToNextPlayer();
                }
                else if (moveChoice is Call)
                {
                    if (currentActor.currentStack != 0)
                    {
                        playersInSession.advanceToNextPlayer();
                    }
                    else
                    {
                        playersInSession.removeCurrentPlayer();
                    }
                }
                else if (moveChoice is Raise)
                {
                    firstPlayerWithNoChoice = currentActor;
                    playersInSession.advanceToNextPlayer();
                }

                if (isFirstPlayersTurn)
                {
                    firstPlayerWithNoChoice = currentActor;
                    isFirstPlayersTurn      = false;
                }
            }
        }