Ejemplo n.º 1
0
        public void AnnulerCoche(Image image)
        {
            pictureBox1.BackgroundImage = image;

            if (MethodesGlobales.CocheXAMettre())
            {
                MethodesGlobales.MettreCocheOAuProchaineClick();
            }
            else
            {
                MethodesGlobales.MettreCocheXAuProchaineClick();
            }
        }
Ejemplo n.º 2
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MethodesGlobales.SauvegarderAvantDerniereCoche(pictureBox1.BackgroundImage);

            if (MethodesGlobales.CocheXAMettre())
            {
                CocherX();
            }
            else
            {
                CocherO();
            }

            MethodesGlobales.DefinirCoordonneeSelectionne(new Coordonnee(_id));
            MethodesGlobales._leThreadTour.Resume();
            //MethodesGlobales.FermerFormeActive();
        }
Ejemplo n.º 3
0
        private void TourDeJeu()
        {
            bool partieTerminee = false;

            Pion unPion = null;

            while (!partieTerminee)
            {
                foreach (IJoueur unJoueur in _mesJoueurs.Values)
                {
                    bool tourTermine = false;

                    if (MethodesGlobales.CocheXAMettre())
                    {
                        unPion = new Pion("X");
                    }
                    else
                    {
                        unPion = new Pion("O");
                    }

                    while (!tourTermine && !partieTerminee)
                    {
                        MessageBox.Show(string.Format("Joueur : {0} à vous de jouer !", unJoueur.GetNom()));

                        MethodesGlobales._leThreadTour.Suspend();

                        Coordonnee uneCoordonnee = unJoueur.Jouer();

                        if (_monTerrain.CaseLibre(uneCoordonnee))
                        {
                            _monTerrain.PoserElement(uneCoordonnee, unPion);

                            if (_monTerrain.VerifierSiJoueurGagne(uneCoordonnee, unPion, _maConfiguration.NbrElementGagnant))
                            {
                                _idGagnant     = unJoueur.GetId();
                                partieTerminee = true;
                            }
                            else if (_monTerrain.TerrainRempli())
                            {
                                partieTerminee = true;
                            }

                            tourTermine = true;
                        }
                        else
                        {
                            MessageBox.Show("Cette case est déjà cochée !");
                            _monTerrain.AnnulerPoseElement(uneCoordonnee, MethodesGlobales.GetSauvegardeAvantDerniereCoche());
                        }
                    }
                }
            }

            if (partieTerminee && !string.IsNullOrEmpty(_idGagnant))
            {
                MessageBox.Show(String.Format("Le gagnant est {0} identifié par l'id {0} !", _mesJoueurs[_idGagnant].GetNom(), _mesJoueurs[_idGagnant].GetId()));
            }
            else
            {
                MessageBox.Show("Aucun vainqueur ! Match nul !");
            }
        }