コード例 #1
0
        public static SummedHandResults GetProbabilitiesPocket(string pocket)
        {
            m_connection = new SqlConnection("Server=localhost;Database=texas;Integrated Security=SSPI;MultipleActiveResultSets=true");
            m_connection.Open();

            SqlCommand pocket_command = new SqlCommand("SELECT player_count, position, pocket, SUM(royal_flush), SUM(straight_flush), SUM(four_of_a_kind), SUM(full_house), SUM(flush), SUM(straight), SUM(three_of_a_kind), SUM(two_pair), SUM(pair), SUM(high_card) FROM results WHERE pocket = @pocket GROUP BY pocket, player_count, position", m_connection);

            pocket_command.Parameters.AddWithValue("@pocket", pocket);

            SummedHandResults result = new SummedHandResults();

            using (SqlDataReader dr = pocket_command.ExecuteReader())
            {
                while (dr.Read())
                {
                    result.player_count    = dr.GetByte(0);
                    result.position        = dr.GetByte(1);
                    result.pocket          = dr.GetString(2);
                    result.royal_flush     = dr.GetInt32(3);
                    result.straight_flush  = dr.GetInt32(4);
                    result.four_of_a_kind  = dr.GetInt32(5);
                    result.full_house      = dr.GetInt32(6);
                    result.flush           = dr.GetInt32(7);
                    result.straight        = dr.GetInt32(8);
                    result.three_of_a_kind = dr.GetInt32(9);
                    result.two_pair        = dr.GetInt32(10);
                    result.pair            = dr.GetInt32(11);
                    result.high_card       = dr.GetInt32(12);
                }
            }

            result.Totals();

            return(result);
        }
コード例 #2
0
        public static void UpdateDisplay(List <CardGUI> deal)
        {
            int cards = deal.Count;

            if (cards < 0)
            {
                MessageBox.Show("What the f**k?!?!");
            }
            else if (cards == 0)
            {
                gui.tb_hand.Clear();
                gui.tb_flop.Clear();
                gui.tb_turn.Clear();
                gui.tb_river.Clear();
            }
            else if (cards == 1)
            {
                string hand = "";
                foreach (CardGUI card in deal)
                {
                    hand += card.ToTextBox() + ",";
                }
                hand = hand.TrimEnd(',');

                gui.tb_hand.Text = hand;
            }
            else if (cards == 2)
            {
                string hand = "";
                foreach (CardGUI card in deal)
                {
                    hand += card.ToTextBox() + ",";
                }
                hand = hand.TrimEnd(',');

                gui.tb_hand.Text = hand;
                SummedHandResults results = GetProbabilitiesPocket(hand);

                gui.tb_royal_flush.Text     = results.RoyalFlushChance().ToString();
                gui.tb_straight_flush.Text  = results.StraightFlushChance().ToString();
                gui.tb_four_of_a_kind.Text  = results.FourOfAKindChance().ToString();
                gui.tb_full_house.Text      = results.FullHouseChance().ToString();
                gui.tb_flush.Text           = results.FlushChance().ToString();
                gui.tb_straight.Text        = results.StraightChance().ToString();
                gui.tb_three_of_a_kind.Text = results.ThreeOfAKindChance().ToString();
                gui.tb_two_pair.Text        = results.TwoPairChance().ToString();
                gui.tb_pair.Text            = results.PairChance().ToString();
                gui.tb_high_card.Text       = results.HighCardChance().ToString();
            }
            else if (cards == 3)
            {
                string flop = "";
                for (int i = 2; i < deal.Count; i++)
                {
                    flop += deal[i].ToTextBox() + ",";
                }
                flop = flop.TrimEnd(',');

                gui.tb_flop.Text = flop;
            }
            else if (cards == 4)
            {
                string flop = "";
                for (int i = 2; i < deal.Count; i++)
                {
                    flop += deal[i].ToTextBox() + ",";
                }
                flop = flop.TrimEnd(',');

                gui.tb_flop.Text = flop;
            }
            else if (cards == 5)
            {
                string flop = "";
                for (int i = 2; i < deal.Count; i++)
                {
                    flop += deal[i].ToTextBox() + ",";
                }
                flop             = flop.TrimEnd(',');
                gui.tb_flop.Text = flop;

                string            hand    = gui.tb_hand.Text;
                SummedHandResults results = GetProbabilitiesFlop(hand, flop);

                gui.tb_royal_flush.Text     = results.RoyalFlushChance().ToString();
                gui.tb_straight_flush.Text  = results.StraightFlushChance().ToString();
                gui.tb_four_of_a_kind.Text  = results.FourOfAKindChance().ToString();
                gui.tb_full_house.Text      = results.FullHouseChance().ToString();
                gui.tb_flush.Text           = results.FlushChance().ToString();
                gui.tb_straight.Text        = results.StraightChance().ToString();
                gui.tb_three_of_a_kind.Text = results.ThreeOfAKindChance().ToString();
                gui.tb_two_pair.Text        = results.TwoPairChance().ToString();
                gui.tb_pair.Text            = results.PairChance().ToString();
                gui.tb_high_card.Text       = results.HighCardChance().ToString();
            }
            else if (cards == 6)
            {
                string turn = "";
                turn += deal[5].ToTextBox() + ",";

                turn             = turn.TrimEnd(',');
                gui.tb_turn.Text = turn;

                string            hand    = gui.tb_hand.Text;
                string            flop    = gui.tb_flop.Text;
                SummedHandResults results = GetProbabilitiesTurn(hand, flop, turn);

                gui.tb_royal_flush.Text     = results.RoyalFlushChance().ToString();
                gui.tb_straight_flush.Text  = results.StraightFlushChance().ToString();
                gui.tb_four_of_a_kind.Text  = results.FourOfAKindChance().ToString();
                gui.tb_full_house.Text      = results.FullHouseChance().ToString();
                gui.tb_flush.Text           = results.FlushChance().ToString();
                gui.tb_straight.Text        = results.StraightChance().ToString();
                gui.tb_three_of_a_kind.Text = results.ThreeOfAKindChance().ToString();
                gui.tb_two_pair.Text        = results.TwoPairChance().ToString();
                gui.tb_pair.Text            = results.PairChance().ToString();
                gui.tb_high_card.Text       = results.HighCardChance().ToString();
            }
            else if (cards == 7)
            {
                string river = "";
                river += deal[6].ToTextBox() + ",";

                river             = river.TrimEnd(',');
                gui.tb_river.Text = river;

                string            hand    = gui.tb_hand.Text;
                string            flop    = gui.tb_flop.Text;
                string            turn    = gui.tb_turn.Text;
                SummedHandResults results = GetProbabilitiesRiver(hand, flop, turn, river);

                gui.tb_royal_flush.Text     = results.RoyalFlushChance().ToString();
                gui.tb_straight_flush.Text  = results.StraightFlushChance().ToString();
                gui.tb_four_of_a_kind.Text  = results.FourOfAKindChance().ToString();
                gui.tb_full_house.Text      = results.FullHouseChance().ToString();
                gui.tb_flush.Text           = results.FlushChance().ToString();
                gui.tb_straight.Text        = results.StraightChance().ToString();
                gui.tb_three_of_a_kind.Text = results.ThreeOfAKindChance().ToString();
                gui.tb_two_pair.Text        = results.TwoPairChance().ToString();
                gui.tb_pair.Text            = results.PairChance().ToString();
                gui.tb_high_card.Text       = results.HighCardChance().ToString();
            }
            else if (cards > 7)
            {
                MessageBox.Show("Too many cards have been selected. Click Reset to start calculations for a new hand.");
            }
        }