Example #1
0
        private void btn_Restart_Click(object sender, RoutedEventArgs e)
        {
            img_P1C1.Source  = null;
            img_P1C2.Source  = null;
            img_P2C1.Source  = null;
            img_P2C2.Source  = null;
            img_Flop1.Source = null;
            img_Flop2.Source = null;
            img_Flop3.Source = null;
            img_Turn.Source  = null;
            img_River.Source = null;

            btn_Table.Content = "Flop";

            try
            {
                Game.Reset();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            btn_Restart.IsEnabled = false;
            btn_Deel.IsEnabled    = true;
        }
Example #2
0
        private void playAmountOfGames(int amount)
        {
            sw.Start();

            for (int i = 0; i < amount; i++)
            {
                Game.Player1.Hand.Add(Game.Deck.DealCard());
                Game.Player2.Hand.Add(Game.Deck.DealCard());
                Game.Player1.Hand.Add(Game.Deck.DealCard());
                Game.Player2.Hand.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());

                Game.DecideWinner();
                gameCount++;

                counters[(int)Game.Player1.BestHand.PokerCombination - 1]++;
                counters[(int)Game.Player2.BestHand.PokerCombination - 1]++;

                Game.Reset();
            }

            lbl_GameCount.Content = gameCount;
            lbl_HandCount.Content = gameCount * 2;

            sw.Stop();
        }
Example #3
0
        private void btn_Run_Click(object sender, RoutedEventArgs e)
        {
            disableRadioButtons();
            btn_Menu.IsEnabled = false;
            int checkedRbtn = getChecked();

            stop = false;
            sw.Reset();

            sw.Start();

            gameCount             = 0;
            lbl_GameCount.Content = gameCount;

            img_P1C1.Source  = null;
            img_P1C2.Source  = null;
            img_P2C1.Source  = null;
            img_P2C2.Source  = null;
            img_Flop1.Source = null;
            img_Flop2.Source = null;
            img_Flop3.Source = null;
            img_Turn.Source  = null;
            img_River.Source = null;

            while (!stop)
            {
                Game.Player1.Hand.Add(Game.Deck.DealCard());
                Game.Player2.Hand.Add(Game.Deck.DealCard());
                Game.Player1.Hand.Add(Game.Deck.DealCard());
                Game.Player2.Hand.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());
                Game.TableCards.Add(Game.Deck.DealCard());

                try
                {
                    Game.DecideWinner();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                gameCount++;

                if ((int)Game.Player1.BestHand.PokerCombination == checkedRbtn || (int)Game.Player2.BestHand.PokerCombination == checkedRbtn)
                {
                    stop = true;
                    lbl_GameCount.Content = gameCount;
                    lbl_HandCount.Content = gameCount * 2;
                    lbl_PointsP1.Content  = Game.Player1.Points;
                    lbl_PointsP2.Content  = Game.Player2.Points;

                    sw.Stop();
                    lbl_Time.Content = sw.ElapsedMilliseconds / 1000.0 + " s";

                    img_P1C1.Source = new BitmapImage(new Uri(Game.Player1.Hand[0].ImagePath(), UriKind.Relative));
                    img_P1C2.Source = new BitmapImage(new Uri(Game.Player1.Hand[1].ImagePath(), UriKind.Relative));
                    img_P2C1.Source = new BitmapImage(new Uri(Game.Player2.Hand[0].ImagePath(), UriKind.Relative));
                    img_P2C2.Source = new BitmapImage(new Uri(Game.Player2.Hand[1].ImagePath(), UriKind.Relative));

                    img_Flop1.Source = new BitmapImage(new Uri(Game.TableCards[0].ImagePath(), UriKind.Relative));
                    img_Flop2.Source = new BitmapImage(new Uri(Game.TableCards[1].ImagePath(), UriKind.Relative));
                    img_Flop3.Source = new BitmapImage(new Uri(Game.TableCards[2].ImagePath(), UriKind.Relative));
                    img_Turn.Source  = new BitmapImage(new Uri(Game.TableCards[3].ImagePath(), UriKind.Relative));
                    img_River.Source = new BitmapImage(new Uri(Game.TableCards[4].ImagePath(), UriKind.Relative));

                    txt_Log.Text += "///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + Environment.NewLine;
                    txt_Log.Text += "---------------------------------------------BINGO!-----------------------------------------------------" + Environment.NewLine;
                    txt_Log.Text += "///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" + Environment.NewLine;

                    txt_Log.Text += String.Format("The flop: {0}, {1}, {2}.", Game.TableCards[0], Game.TableCards[1], Game.TableCards[2]) + Environment.NewLine;
                    txt_Log.Text += String.Format("The turn: {0}.", Game.TableCards[3]) + Environment.NewLine;
                    txt_Log.Text += String.Format("The river: {0}.", Game.TableCards[4]) + Environment.NewLine;
                    txt_Log.Text += Game.Player1.Name + " has " + PokerHelp.PokerCombinationToString(Game.Player1.BestHand.PokerCombination) + Environment.NewLine;
                    txt_Log.Text += Game.Player2.Name + " has " + PokerHelp.PokerCombinationToString(Game.Player2.BestHand.PokerCombination) + Environment.NewLine;
                    if (Game.Player1.Won && !Game.Player2.Won)
                    {
                        txt_Log.Text += Game.Player1.Name + " wins!" + Environment.NewLine;
                    }
                    else if (Game.Player2.Won && !Game.Player1.Won)
                    {
                        txt_Log.Text += Game.Player2.Name + " wins!" + Environment.NewLine;
                    }
                    else if (Game.Player1.Won && Game.Player2.Won)
                    {
                        txt_Log.Text += "Split pot!" + Environment.NewLine;
                    }
                    txt_Log.Text += Environment.NewLine;
                }
                else
                {
                    Game.Reset();
                }
            }

            Game.Reset();
            enableRadioButtons();
            btn_Menu.IsEnabled = true;
        }