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); }); }
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); }
public void Visit(Bishop bishop) { PieceType = "Bishop"; }