예제 #1
0
 bool IsLegalMove(ChessPiece pieceUserWantToMove, Location target, ref string message)
 {
     if ((IsWhiteTurn() && !pieceUserWantToMove.isWhite) || (!IsWhiteTurn() && pieceUserWantToMove.isWhite))
     {
         message = "Not your turn!!!";
         return(false);
     }
     else if (target.x > 7 || target.x < 0 || target.y < 0 || target.y > 7)
     {
         message = "Stay in game boundries!!";
         return(false);
     }
     else if (board.GetSquareData(target) != null && board.GetSquareData(target).isWhite == pieceUserWantToMove.isWhite)
     {
         message = "Can't put piece on your own piece!!!";
         return(false);
     }
     else if (!pieceUserWantToMove.IsLegalMove(target))
     {
         message = "Iligal move!";
         return(false);
     }
     else if ((pieceUserWantToMove.IsInCheck() && !pieceUserWantToMove.IsMoveBlockCheck(target)) || pieceUserWantToMove.IsMoveMakeCheck(target))
     {
         message = "CHECK BLAT!!";
         return(false);
     }
     return(true);
 }