예제 #1
0
 //most important method in the game, controls the turns of the players
 private void TimerNextMove_Tick(object sender, EventArgs e)
 {
     timerCount++;
     //condition if everyone folds
     if (pokerTable.PlayerWon()) {
         panelBubble.Hide();
         pokerTable.setCurrentIndex(pokerTable.incrementIndexShowdown(pokerTable.getCurrentIndex()));
         pokerTable[pokerTable.getCurrentIndex()].CollectMoney(pokerTable.getPot());
         lblBanner.Text = pokerTable[pokerTable.getCurrentIndex()].Message;
         lblBanner.Show();
         TimerNextMove.Stop();
         TimerWait3Seconds.Start();
         return;
     }
     //condition to increment player's turn
     if (pokerTable.beginNextTurn()) {
         pokerTable.setCurrentIndex(pokerTable.incrementIndex(pokerTable.getCurrentIndex()));
         lblBanner.Hide();
         //condition to pay small/big blind
         if (timerCount == 1)
             pokerTable.PaySmallBlind();
         else if (timerCount == 2)
             pokerTable.PayBigBlind();
         //condition that the current player is not AI, show labels to player
         else if (pokerTable.getCurrentIndex() == 0) {
             initalizeButtons();
             TimerNextMove.Stop();
             return;
         }
         //condition for AI
         else {
             AIPlayer currentPlayer = (AIPlayer) pokerTable[pokerTable.getCurrentIndex()];
             if (difficulty == (int) DIFFICULTY.HARD) {
                 Hand holeCards = new Hand();
                 holeCards.Add(pokerTable[0].getHand()[0]);
                 holeCards.Add(pokerTable[0].getHand()[1]);
                 currentPlayer.CalculateHandValueHard(holeCards, new Deck(pokerTable.getDeck()));
             }
             currentPlayer.MakeADecision(pokerTable.getPot(), pokerTable.decrementIndex(pokerTable.getCurrentIndex()));
             pokerTable[pokerTable.getCurrentIndex()] = currentPlayer;
             //grey out form if the AI folds
             if (currentPlayer.IsFolded())
                 panelList[pokerTable.getCurrentIndex()].BackgroundImage = Image.FromFile("inactivebutton.png");
         }
         updateMove();
         if (timerCount > 2 && pokerTable.getCurrentIndex() != 0 && difficulty == 1) {
             timerCalculate.Start();
         }
     }
     else {
         //deal community cards
         pokerTable.TurnCount = 0;
         lblBanner.Show();
         panelBubble.Hide();
         if (pokerTable[0].getHand().Count() == 2) {
             pokerTable.DealFlop();
             lblBanner.Text = "Dealing the Flop";
             toolTipHint.SetToolTip(panelPlayer, HandCombination.getBestHand(new Hand(pokerTable[0].getHand())).ToString());
         }
         else if (pokerTable[0].getHand().Count() == 5) {
             pokerTable.DealTurn();
             lblBanner.Text = "Dealing the Turn";
             toolTipHint.SetToolTip(panelPlayer, HandCombination.getBestHand(new Hand(pokerTable[0].getHand())).ToString());
         }
         else if (pokerTable[0].getHand().Count() == 6) {
             pokerTable.DealRiver();
             lblBanner.Text = "Dealing the River";
             toolTipHint.SetToolTip(panelPlayer, HandCombination.getBestHand(new Hand(pokerTable[0].getHand())).ToString());
         }
         else if (pokerTable[0].getHand().Count() == 7) {
             //start timer for showdown
             lblBanner.Text = "Showdown";
             TimerNextMove.Stop();
             TimerShowdown.Start();
             return;
         }
         //reset agressor the dealer
         int dealerPosition = pokerTable.getDealerPosition();
         pokerTable.setCurrentIndex(pokerTable.getDealerPosition());
         pokerTable.getPot().AgressorIndex = pokerTable.getDealerPosition();
         DrawToScreen();
     }
 }