Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void CheckFinished()
        {
            if (board.IsFinished())
            {
                // Partie terminée
                var scoreBlack = board.GetBlackScore();
                var scoreWhite = board.GetWhiteScore();
                UpdateUI(true);

                // Affichage du gagnant
                string winner;
                if (scoreBlack > scoreWhite)
                {
                    winner = $"Gagnant : {NOIR}";
                }
                else if (scoreWhite > scoreBlack)
                {
                    winner = $"Gagnant : {BLANC}";
                }
                else
                {
                    winner = "Match nul";
                }

                var m = MessageBox.Show($"Score joueur noir : {board.GetBlackScore()}\nScore joueur blanc : {board.GetWhiteScore()}\n{winner}\n\nSouhaitez-vous relancer une partie ?", "Partie terminée !", MessageBoxButton.YesNo);
                if (m == MessageBoxResult.Yes)
                {
                    // Recommence une partie
                    StartGame();
                }
                else
                {
                    // Ferme l'application
                    Close();
                }
            }
            else
            {
                // Partie pas terminée
                UpdateUI(false);
                contextPlayers.WhiteTurn = whiteTurn;
                contextPlayers.Timer.Start();
            }
        }