Example #1
0
        public void remplirGrille(int indice)
        {
            string gagnant = "";
            string O_X     = (joueur_1.Tour) ? joueur_1.Caractere : joueur_2.Caractere;

            _grille.remplirCase(O_X, indice);
            joueur_1.Tour            = !joueur_1.Tour;
            joueur_2.Tour            = !joueur_2.Tour;
            nom_joueur_2.BorderStyle = (joueur_2.Tour) ? BorderStyle.FixedSingle : BorderStyle.None;
            nom_joueur_1.BorderStyle = (joueur_1.Tour) ? BorderStyle.FixedSingle : BorderStyle.None;
            if (Partie_non_fini())
            {
                Play();
            }
            else
            {
                switch (gameStateCheck())
                {
                case SYMBOL_1:
                    gagnant = "vous avez gagné";
                    break;

                case SYMBOL_2:
                    gagnant = "vous avez perdu";
                    break;

                default:
                    gagnant = "match nul";
                    break;
                }

                string stateCheck = gameStateCheck();
                switch (stateCheck)
                {
                case SYMBOL_1:
                    gagnant = "gagné";
                    break;

                case SYMBOL_2:
                    gagnant = "perdu";
                    break;

                case "d":
                    gagnant = "match nul";
                    break;

                default:
                    gagnant = "statut de la partie indéterminé";
                    break;
                }

                DialogResult dialogResult = MessageBox.Show(
                    "Partie terminée : " + gagnant + " \n\nVoulez-vous rejouez?", "Partie terminé",
                    MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    createNewGame();
                }
                else if (dialogResult == DialogResult.No)
                {
                    Application.Exit();
                }
            }
        }