예제 #1
0
        public string GetWhiteStatus()
        {
            var underCheck = CheckForWhite();
            var canMove    = false;

            foreach (Loc figureLocation in board.Figures(Cell.White))
            {
                foreach (Loc figureMoves in board.Get(figureLocation).Figure.Moves(figureLocation, board))
                {
                    Cell oldDest = board.PerformMove(figureLocation, figureMoves);
                    if (!CheckForWhite( ))
                    {
                        canMove = true;
                    }
                    board.PerformUndoMove(figureLocation, figureMoves, oldDest);
                }
            }
            if (underCheck)
            {
                if (canMove)
                {
                    return("check");
                }
                else
                {
                    return("mate");
                }
            }
            if (canMove)
            {
                return("ok");
            }
            return("stalemate");
        }
예제 #2
0
        public string GetWhiteStatus()
        {
            bool check         = checkToWhiteKing();
            bool checkNextMove = true;

            foreach (Loc oldFigureLoc in board.Figures(Cell.White))
            {
                foreach (Loc newFigureLoc in board.Get(oldFigureLoc).Figure.Moves(oldFigureLoc, board))
                {
                    Cell destCell = board.PerformMove(oldFigureLoc, newFigureLoc);
                    if (!checkToWhiteKing())
                    {
                        checkNextMove = false;
                        break;
                    }
                    board.PerformUndoMove(oldFigureLoc, newFigureLoc, destCell);
                }
            }
            if (check)
            {
                return(checkNextMove ? "mate" : "check");
            }
            else if (checkNextMove)
            {
                return("stalemate");
            }
            else
            {
                return("ok");
            }
        }