Exemplo n.º 1
0
        private void AfficherTour(bool estBlanc)
        {
            var ret = Plateau.GetMaxPrisesPossible(estBlanc);

            if (ret > 0)
            {
                ui.AfficherTour(estBlanc, "Les " + (estBlanc ? "Blancs" : "Noirs") + " doivent prendre " + ret + " pions.");
            }
            else
            {
                ui.AfficherTour(estBlanc, "C'est aux " + (estBlanc ? "Blancs" : "Noirs") + " de jouer.");
            }
        }
Exemplo n.º 2
0
        public async Task Jouer(CancellationToken annulation)
        {
            ui.AfficherPlateau(Plateau);

            await Task.Run(() =>
            {
                try
                {
                    while (true)
                    {
                        AfficherTour(true);
                        if (!Plateau.Effectuer(JoueurB.Jouer(new Plateau(Plateau), annulation), true))
                        {
                            Console.WriteLine("Les Blancs ont voulu jouer un coup incorrect");
                            throw new Exception("debug");
                        }
                        Plateau.FairePromotions();
                        Console.WriteLine("fin tour Blancs");
                        ui.AfficherPlateau(Plateau);
                        if (VerifierGagnant(true))
                        {
                            return;
                        }
                        ;

                        AfficherTour(false);
                        if (!Plateau.Effectuer(JoueurN.Jouer(new Plateau(Plateau), annulation), false))
                        {
                            Console.WriteLine("Les Noirs ont voulu jouer un coup incorrect");
                        }
                        Plateau.FairePromotions();
                        Console.WriteLine("fin tour Noirs");
                        ui.AfficherPlateau(Plateau);
                        if (VerifierGagnant(false))
                        {
                            return;
                        }
                        ;
                    }
                }
                catch (OperationCanceledException)
                {
                    Console.Write("Partie Annulee ");
                    return;
                }
            }, annulation).ContinueWith((precedant) =>
            {
                Console.WriteLine(precedant.Status);
            });
        }
Exemplo n.º 3
0
        public override Mouvement Jouer(Plateau plateau, CancellationToken annulation)
        {
            aLeTrait   = true;
            plateauTMP = plateau;
            var valide = false;

            mouvement = null;
            Mouvement mouvFinal = null;

            while (!valide)
            {
                mouvement = null;
                aJoue     = new TaskCompletionSource <Mouvement>(annulation);
                annulation.Register(() => aJoue.TrySetCanceled(annulation), true);
                nbDePrisesTmp = 0;

                try
                {
                    mouvFinal = aJoue.Task.Result;
                }
                catch (AggregateException)
                {
                    throw new OperationCanceledException();
                }

                Console.WriteLine("mouv choisi");
                Plateau test = new Plateau(plateau);
                valide = test.Effectuer(mouvFinal, EstBlanc);

                if (!valide)
                {
                    deselectionnerToutesLesCases();
                    deselectionnerToutesLesCases = null;
                    Console.WriteLine("Mouvement invalide");
                }
            }

            deselectionnerToutesLesCases();
            deselectionnerToutesLesCases = null;
            aLeTrait = false;
            return(mouvFinal);
        }
Exemplo n.º 4
0
 public abstract Mouvement Jouer(Plateau plateau, CancellationToken annulation);
Exemplo n.º 5
0
 public Plateau(Plateau autre)
 {
     Grille = (Piece[, ])autre.Grille.Clone();
 }