示例#1
0
 private void SetupBishops()
 {
     Bishop.PossibleStartingPositions(PieceColor.Black).ToList().ForEach(p =>
     {
         var peice = new Bishop(PieceColor.Black, this);
         AddReplace(peice, p.Item1, p.Item2);
     });
     Bishop.PossibleStartingPositions(PieceColor.White).ToList().ForEach(p =>
     {
         var peice = new Bishop(PieceColor.White, this);
         AddReplace(peice, p.Item1, p.Item2);
     });
 }
示例#2
0
        public bool PromotePawn(int row, int col, PieceColor color, string type)
        {
            var piece       = GetPiece(row, col);
            var requiredRow = color == PieceColor.Black
                                ? ChessConstants.MAX_BOARD_ROWS - 1
                                : 0;
            ChessPiece newPiece;
            bool       hasPromoted = false;

            if (piece != null && row == requiredRow && piece.PieceColor == color && piece.GetType() == typeof(Pawn))
            {
                piece.Accept(this);
                switch (PieceType)
                {
                case "Queen":
                    newPiece    = new Queen(color, this);
                    hasPromoted = SwitchPiece(piece, newPiece);
                    break;

                case "Bishop":
                    newPiece    = new Bishop(color, this);
                    hasPromoted = SwitchPiece(piece, newPiece);
                    break;

                case "Knight":
                    newPiece    = new Knight(color, this);
                    hasPromoted = SwitchPiece(piece, newPiece);
                    break;

                case "Rook":
                    newPiece    = new Rook(color, this);
                    hasPromoted = SwitchPiece(piece, newPiece);
                    break;

                default:
                    break;
                }
            }
            return(hasPromoted);
        }
示例#3
0
 public void Visit(Bishop bishop)
 {
     PieceType = "Bishop";
 }