Beispiel #1
0
        private void button_Click(Object sender, EventArgs e)
        {
            var button = sender as Button;
            int val    = 0;

            if (Int32.TryParse(button.Text, out val))
            {
                tic.ChooseCell(val = val - 1);
                button.Text        = tic.getACell(val).getText();

                if (tic.getStatus() == GameStatus.PlayerXWins)
                {
                    System.Windows.Forms.MessageBox.Show("Speler x wint!");
                    maakLeeg();
                    tic.Reset();
                }

                else if (tic.getStatus() == GameStatus.PlayerXPlays)
                {
                    System.Windows.Forms.MessageBox.Show("Speler x speelt!");
                }

                else if (tic.getStatus() == GameStatus.PlayerOPlays)
                {
                    System.Windows.Forms.MessageBox.Show("Speler o speelt!");
                }


                else if (tic.getStatus() == GameStatus.PlayerOWins)
                {
                    System.Windows.Forms.MessageBox.Show("Speler o wint!");
                    maakLeeg();
                    tic.Reset();
                }

                else if (tic.getStatus() == GameStatus.PlayerXWins)
                {
                    System.Windows.Forms.MessageBox.Show("Speler x wint!");
                    maakLeeg();
                    tic.Reset();
                }

                else if (tic.getStatus() == GameStatus.Equal)
                {
                    System.Windows.Forms.MessageBox.Show("Gelijk spel!");
                    maakLeeg();
                    tic.Reset();
                }
            }

            else
            {
                System.Windows.Forms.MessageBox.Show("Geen geldige cell!");
            }
        }
Beispiel #2
0
 public Form1()
 {
     InitializeComponent();
     this.tic = new TicTacToe();
     tic.Reset();
 }