Esempio n. 1
0
        private void CheckForMate()
        {
            pState.ResetGameState();

            CheckForMate(FigureColor.BLACK);
            CheckForMate(FigureColor.WHITE);

            PlayerState black = pState.GetState(FigureColor.BLACK);
            PlayerState white = pState.GetState(FigureColor.WHITE);


            if (black == PlayerState.CHECK)
            {
                playWindow.PrintToConsole("System: ", System.Drawing.Color.Red);
                playWindow.PrintToConsoleLn("Player 2: check!", System.Drawing.Color.Black);
            }
            else if (black == PlayerState.CHECKMATE)
            {
                playWindow.PrintToConsole("System: ", System.Drawing.Color.Red);
                playWindow.PrintToConsoleLn("Player 2: mate!", System.Drawing.Color.Black);

                MessageBox.Show("Player 2 mate!");
            }

            if (white == PlayerState.CHECK)
            {
                playWindow.PrintToConsole("System: ", System.Drawing.Color.Red);
                playWindow.PrintToConsoleLn("Player 2: check!", System.Drawing.Color.Black);
            }
            else if (white == PlayerState.CHECKMATE)
            {
                playWindow.PrintToConsole("System: ", System.Drawing.Color.Red);
                playWindow.PrintToConsoleLn("Player 1: mate!", System.Drawing.Color.Black);

                MessageBox.Show("Player 1 mate!");
            }

            if (pState.GetState(FigureColor.BLACK) == PlayerState.CHECKMATE ||
                pState.GetState(FigureColor.WHITE) == PlayerState.CHECKMATE)
            {
                EndGame();
            }
        }
Esempio n. 2
0
        private void CheckForMate()
        {
            Program.Debug("Checking state...");
            pState.ResetGameState();

            CheckForMate(FigureColor.BLACK);
            CheckForMate(FigureColor.WHITE);

            PlayerState black = pState.GetState(FigureColor.BLACK);
            PlayerState white = pState.GetState(FigureColor.WHITE);


            if (black == PlayerState.CHECK)
            {
                playWindow.PrintToConsole("System: ", System.Drawing.Color.Red);
                playWindow.PrintToConsoleLn("Player 2: check!", System.Drawing.Color.Black);
                if (network != null && pCollection.Current != null)
                {
                    pCollection.Current.IncrementScore();
                }
            }
            else if (black == PlayerState.CHECKMATE)
            {
                playWindow.PrintToConsole("System: ", System.Drawing.Color.Red);
                playWindow.PrintToConsoleLn("Player 2: mate!", System.Drawing.Color.Black);
                if (network != null && pCollection.Current != null && runColor == FigureColor.BLACK)
                {
                    pCollection.Current.GameWon(0);
                }
                if (network != null && pCollection.Current != null && runColor == FigureColor.WHITE)
                {
                    pCollection.Current.GameLost(0);
                }
                MessageBox.Show("Player 2 mate!");
            }

            if (white == PlayerState.CHECK)
            {
                playWindow.PrintToConsole("System: ", System.Drawing.Color.Red);
                playWindow.PrintToConsoleLn("Player 2: check!", System.Drawing.Color.Black);
                if (network != null && pCollection.Current != null)
                {
                    pCollection.Current.IncrementScore();
                }
            }
            else if (white == PlayerState.CHECKMATE)
            {
                playWindow.PrintToConsole("System: ", System.Drawing.Color.Red);
                playWindow.PrintToConsoleLn("Player 1: mate!", System.Drawing.Color.Black);
                if (network != null && pCollection.Current != null && runColor == FigureColor.WHITE)
                {
                    pCollection.Current.GameWon(0);
                }
                if (network != null && pCollection.Current != null && runColor == FigureColor.BLACK)
                {
                    pCollection.Current.GameLost(0);
                }
                MessageBox.Show("Player 1 mate!");
            }

            if (pState.GetState(FigureColor.BLACK) == PlayerState.CHECKMATE ||
                pState.GetState(FigureColor.WHITE) == PlayerState.CHECKMATE)
            {
                EndGame();
            }
        }