示例#1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            // check if all MAX_PLAYERS players are in the game already
            if (GetActivePlayers().Count() == BlackjackGame.MAX_PLAYERS)
            {
                MessageBox.Show(string.Format(
                                    "You can't add a new player to the game!\nAll {0} players are in the game!",
                                    BlackjackGame.MAX_PLAYERS));
                return;
            }

            // try adding new player
            AddPlayerForm form = new AddPlayerForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                BlackjackResult res = new BlackjackResult();
                res.player   = form.GetPlayer();
                res.results  = new List <PlayerResult>();
                res.shuffles = new List <int>();
                res.stakes   = new List <int>();

                GameStats.gameResults.Add(res);

                // find the current shuffle (current column in the stats table)
                int nColumns = TotalColumns();

                ListViewItem item = new ListViewItem(string.Format("{0} ({1} $)", form.GetPlayer().Name, form.GetPlayer().Money));
                listViewPlayers.Items.Add(item);

                for (int i = 0; i < nColumns; i++)
                {
                    item.SubItems.Add("");
                }

                ShowStatistics();

                ChangedPlayer = true;
            }
        }
示例#2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            // check if all MAX_PLAYERS players are in the game already
            if (GetActivePlayers().Count() == BlackjackGame.MAX_PLAYERS)
            {
                MessageBox.Show( string.Format(
                                    "You can't add a new player to the game!\nAll {0} players are in the game!",
                                    BlackjackGame.MAX_PLAYERS ) );
                return;
            }

            // try adding new player
            AddPlayerForm form = new AddPlayerForm();
            if (form.ShowDialog() == DialogResult.OK)
            {
                BlackjackResult res = new BlackjackResult();
                res.player = form.GetPlayer();
                res.results = new List<PlayerResult>();
                res.shuffles = new List<int>();
                res.stakes = new List<int>();

                GameStats.gameResults.Add( res );

                // find the current shuffle (current column in the stats table)
                int nColumns = TotalColumns();

                ListViewItem item = new ListViewItem(string.Format("{0} ({1} $)", form.GetPlayer().Name, form.GetPlayer().Money) );
                listViewPlayers.Items.Add(item);

                for (int i = 0; i < nColumns; i++)
                {
                    item.SubItems.Add("");
                }

                ShowStatistics();

                ChangedPlayer = true;
            }
        }