Ejemplo n.º 1
0
 //timer to take care of showdown situations
 private void TimerShowdown_Tick(object sender, EventArgs e)
 {
     showdownCount++;
     if (showdownCount > pokerTable.getPot().getPlayersInPot().Count)
     {
         //unhighlights hands and evaluates hands to determine winner(s)
         for (int i = 0; i < pokerTable[pokerTable.getCurrentIndex()].getHand().Count(); i++)
         {
             pokerTable[pokerTable.getCurrentIndex()].getHand()[i].UnHighlight();
         }
         DrawToScreen();
         pokerTable.ShowDown();
         lblBanner.Text = pokerTable.winnermessage;
         TimerShowdown.Stop();
         TimerWait3Seconds.Start();
     }
     else
     {
         //displays hands to the user
         for (int i = 0; i < pokerTable[pokerTable.getCurrentIndex()].getHand().Count(); i++)
         {
             pokerTable[pokerTable.getCurrentIndex()].getHand()[i].UnHighlight();
         }
         int currentIndex = pokerTable.incrementIndexShowdown(pokerTable.getCurrentIndex());
         pokerTable.setCurrentIndex(currentIndex);
         pokerTable[currentIndex].getHand()[0].FaceUp = true;
         pokerTable[currentIndex].getHand()[1].FaceUp = true;
         Hand bestHand = HandCombination.getBestHand(new Hand(pokerTable[currentIndex].getHand()));
         for (int i = 0; i < pokerTable[currentIndex].getHand().Count(); i++)
         {
             for (int j = 0; j < bestHand.Count(); j++)
             {
                 if (bestHand.getCard(j) == pokerTable[currentIndex].getHand().getCard(i) && bestHand.getCard(j).getSuit() == pokerTable[currentIndex].getHand().getCard(i).getSuit())
                 {
                     pokerTable[currentIndex].getHand().getCard(i).Highlight();
                 }
             }
         }
         lblBanner.Text = pokerTable[currentIndex].Name + " has: " + Environment.NewLine +
                          bestHand.ToString();
         DrawToScreen();
     }
 }
Ejemplo n.º 2
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();
     }
 }