Esempio n. 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // firstly, show the Players form
            PlayersForm form = new PlayersForm();

            // if we added at least one player and pressed OK, then start:
            if (form.ShowDialog() == DialogResult.OK)
            {
                statistics = form.GameStats;

                // create new game object
                game = new BlackjackGame();

                // initialize visualizer
                gamevisualizer = new CardTableVisualizer(game);
                gamevisualizer.PrepareGraphics(this.Width, this.Height, CreateGraphics());

                // initialize controller:
                // pass the game and visualizer objects
                // and the FixGameResults() function as the function that will be called when the game's over
                gamecontroller = new CardTableController(game, gamevisualizer, FixGameResults);

                // set the list of active players for a new game
                game.SetPlayerList( form.GetActivePlayers() );

                // start new game
                NewGame();
            }
            else
            {
                Close();
            }
        }
Esempio n. 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // firstly, show the Players form
            PlayersForm form = new PlayersForm();

            // if we added at least one player and pressed OK, then start:
            if (form.ShowDialog() == DialogResult.OK)
            {
                statistics = form.GameStats;

                // create new game object
                game = new BlackjackGame();

                // initialize visualizer
                gamevisualizer = new CardTableVisualizer(game);
                gamevisualizer.PrepareGraphics(this.Width, this.Height, CreateGraphics());

                // initialize controller:
                // pass the game and visualizer objects
                // and the FixGameResults() function as the function that will be called when the game's over
                gamecontroller = new CardTableController(game, gamevisualizer, FixGameResults);

                // set the list of active players for a new game
                game.SetPlayerList(form.GetActivePlayers());

                // start new game
                NewGame();
            }
            else
            {
                Close();
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Controller's constructor sets the objects passed as parameters
 /// </summary>
 /// <param name="blackjackgame">The game object</param>
 /// <param name="gamevisualizer">The visualizer object</param>
 /// <param name="handler">The GameOver event handler (caller's function - in our case it's in the MainForm)</param>
 public CardTableController( BlackjackGame blackjackgame, CardTableVisualizer gamevisualizer, GameOverHandler handler )
 {
     game = blackjackgame;
     cardtable = gamevisualizer;
     GameOver += handler;
 }
Esempio n. 4
0
 /// <summary>
 /// Controller's constructor sets the objects passed as parameters
 /// </summary>
 /// <param name="blackjackgame">The game object</param>
 /// <param name="gamevisualizer">The visualizer object</param>
 /// <param name="handler">The GameOver event handler (caller's function - in our case it's in the MainForm)</param>
 public CardTableController(BlackjackGame blackjackgame, CardTableVisualizer gamevisualizer, GameOverHandler handler)
 {
     game      = blackjackgame;
     cardtable = gamevisualizer;
     GameOver += handler;
 }