コード例 #1
0
 //timer to start next round
 private void TimerWait3Seconds_Tick(object sender, EventArgs e)
 {
     if (PlayerBustedOut())
     {
         TimerWait3Seconds.Stop();
         timerBusted.Start();
         return;
     }
     matchStart();
     TimerWait3Seconds.Stop();
 }
コード例 #2
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();
     }
 }
コード例 #3
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();
     }
 }
コード例 #4
0
 public void matchStart()
 {
     if (PlayerWon() != 0)
     {
         TimerWait3Seconds.Stop();
         lblBanner.Hide();
         //Checks if the player has won at start of new round
         if (PlayerWon() == 1)
         {
             if (user.getUserName() != "default" && user.getPassword() != "default")
             {
                 user.AddWin();
                 user.WriteToFile();
             }
             panelBubble.Hide();
             FormEndGame FormEndGame = new FormEndGame(true);
             FormEndGame.StartPosition = FormStartPosition.CenterScreen;
             FormEndGame.FormPoker     = this;
             FormEndGame.Text          = "You won!";
             FormEndGame.ShowDialog();
         }
         else if (PlayerWon() == -1)
         {
             if (user.getUserName() != "default" && user.getPassword() != "default")
             {
                 user.AddLose();
                 user.WriteToFile();
             }
             panelBubble.Hide();
             FormEndGame FormEndGame = new FormEndGame(false);
             FormEndGame.StartPosition = FormStartPosition.CenterScreen;
             FormEndGame.FormPoker     = this;
             FormEndGame.Text          = "You lost!";
             FormEndGame.ShowDialog();
         }
         return;
     }
     HideControls();
     for (int i = 0; i < pokerTable.getPlayers().Count; i++)
     {
         if (pokerTable[i].IsFolded())
         {
             panelList[i].BackgroundImage = Image.FromFile("panelNormal.png");
         }
     }
     //resetting variables to start new match
     timerCount    = 0;
     showdownCount = 0;
     lblBanner.Show();
     if (pokerTable.RoundCount == 10)
     {
         lblBanner.Text = "The minimum blinds have" + Environment.NewLine + "been raised";
     }
     else
     {
         lblBanner.Text = "New Round";
     }
     pokerTable.startNextMatch();
     pokerTable.DealHoleCards();
     DrawToScreen();
     updateMove();
     lblBubble.Text = pokerTable[pokerTable.getCurrentIndex()].Name + " is the dealer";
     TimerNextMove.Start();
 }