示例#1
0
        //calculate hand value for AI, if necessary, which takes a long time
        private void timerCalculate_Tick(object sender, EventArgs e)
        {
            AIPlayer nextPlayer       = (AIPlayer)(pokerTable[pokerTable.getCurrentIndex()]);
            int      playersCompeting = 0;

            for (int i = 0; i < pokerTable.getPlayers().Count; i++)
            {
                if (pokerTable[i].isbusted || pokerTable[i].IsFolded())
                {
                    continue;
                }
                playersCompeting++;
            }
            nextPlayer.CalculateHandValue(playersCompeting);

            timerCalculate.Stop();
        }
示例#2
0
        private void btnHandValue_Click(object sender, EventArgs e)
        {
            int       index         = lbMain.SelectedIndex;
            AIPlayer  currentPlayer = (AIPlayer)pokerTable[index];
            Stopwatch timer         = new Stopwatch();

            timer.Start();
            Hand hand = new Hand();

            hand.Add(new Card(RANK.TWO, SUIT.SPADES));
            hand.Add(new Card(RANK.FOUR, SUIT.DIAMONDS));
            currentPlayer.CalculateHandValue(playerAmount);
            timer.Stop();
            pokerTable[index] = currentPlayer;
            rtbOutput.Text    = currentPlayer.HandValue.ToString() + Environment.NewLine + timer.Elapsed.TotalMilliseconds;

            lbMain.Items.Clear();
            foreach (Player player in pokerTable)
            {
                lbMain.Items.Add(player.Name);
            }
            lbMain.SelectedIndex = index;
        }