Beispiel #1
0
 //allin button
 private void btnAllIn_Click(object sender, EventArgs e)
 {
     pokerTable[0].AllIn(pokerTable.getPot(), pokerTable.decrementIndex(pokerTable.getCurrentIndex()));
     updateMove();
     HideButtons();
     TimerNextMove.Start();
 }
Beispiel #2
0
 //bet/raise button
 private void btnRaise_Click(object sender, EventArgs e)
 {
     if (pokerTable[pokerTable.getCurrentIndex()].getAmountToCall(pokerTable.getPot()) == 0)
     {
         getMoney.Text = "Bet";
         getMoney.lblRaiseAmount.Text = "Bet Amount: ";
     }
     else
     {
         getMoney.Text = "Raise";
         getMoney.lblRaiseAmount.Text = "Raise Amount: ";
     }
     getMoney.setMoney(pokerTable.getPot().MinimumRaise, (pokerTable[0].ChipStack - pokerTable[0].getAmountToCall(pokerTable.getPot())));
     if (getMoney.ShowDialog() != DialogResult.OK)
     {
         return;
     }
     if (pokerTable[pokerTable.getCurrentIndex()].getAmountToCall(pokerTable.getPot()) != 0)
     {
         pokerTable[0].Raise(Convert.ToInt32(getMoney.nudBetRaise.Value), pokerTable.getPot(), pokerTable.decrementIndex(pokerTable.getCurrentIndex()));
     }
     else
     {
         pokerTable[0].Bet(Convert.ToInt32(getMoney.nudBetRaise.Value), pokerTable.getPot(), pokerTable.decrementIndex(pokerTable.getCurrentIndex()));
     }
     updateMove();
     HideButtons();
     TimerNextMove.Start();
 }
Beispiel #3
0
 //fold button
 private void btnFold_Click(object sender, EventArgs e)
 {
     pokerTable[0].Fold(pokerTable.getPot());
     updateMove();
     HideButtons();
     panelPlayer.BackgroundImage = Image.FromFile("inactivebutton.png");
     TimerNextMove.Start();
 }
Beispiel #4
0
 //check/call button
 private void btnCheck_Click(object sender, EventArgs e)
 {
     if (pokerTable[pokerTable.getCurrentIndex()].getAmountToCall(pokerTable.getPot()) != 0)
     {
         pokerTable[0].Call(pokerTable.getPot());
     }
     else
     {
         pokerTable[0].Check(pokerTable.getPot());
     }
     updateMove();
     HideButtons();
     TimerNextMove.Start();
 }
Beispiel #5
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();
     }
 }
Beispiel #6
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();
 }