package chessGame;

public class Bishop extends ChessPiece {
	private final int score=30;
	private final int rank=3;

	public Bishop(ChessPlayer player, String position) {
		super(player, position);	
	}
	
	@Override
	public boolean isValidMove(String moveTo) {
		// TO-DO: add Exception out of the board scope 
		// throw new UnsupportedOperationException();
		// TO-DO: Exception own chess
		
		if(position==moveTo)
			return false;
		
		ChessMonitoringSystem CMS = ChessMonitoringSystem.getInstance();
		if(CMS.getChessPiece(moveTo)==null || 
				CMS.getChessPiece(moveTo).getPlayer()!=this.player)
		{
			int numOfMoves=0;
			ChessPiece tempChess=null;
			boolean isBlocked=false;
			
			//Character.toChars(x)
			//Integer.toString(i)
			
			int xPosDiff = position.charAt(0)-moveTo.charAt(0);
			int yPosDiff = position.charAt(1)-moveTo.charAt(1);
			
			if(Math.abs(yPosDiff)==
					Math.abs(xPosDiff))
			{
				// top left corner
				if(xPosDiff>0 &&
						yPosDiff<0)	
				{
					numOfMoves=xPosDiff;
					//check any pieces in the middle (position to moveTo)
					for(int i=1;i<numOfMoves;i++)
					{
						String yPosString = String.valueOf(position.charAt(1)+i);
						tempChess=CMS.getChessPiece((char)(position.charAt(0)-i)+yPosString);//wrong formatting
						if(tempChess!=null)
							isBlocked=true;
					}	
				}
				// lower left corner
				if(xPosDiff>0 &&
						yPosDiff>0)	
				{
					numOfMoves=xPosDiff;
					//check any pieces in the middle (position to moveTo)
					for(int i=1;i<numOfMoves;i++)
					{
						String yPosString = String.valueOf(position.charAt(1)-i);
						tempChess=CMS.getChessPiece((char)(position.charAt(0)-i)+yPosString);//wrong formatting
						if(tempChess!=null)
							isBlocked=true;
					}	
				}
				// top right corner
				if(xPosDiff<0 &&
						yPosDiff<0)	
				{
					numOfMoves=(moveTo.charAt(0)-position.charAt(0));
					//check any pieces in the middle (position to moveTo)
					for(int i=1;i<numOfMoves;i++)
					{
						String yPosString = String.valueOf(position.charAt(1)+i);
						tempChess=CMS.getChessPiece((char)(position.charAt(0)+i)+yPosString);//wrong formatting
						if(tempChess!=null)
							isBlocked=true;
					}	
				}
				// lower right corner
				if(xPosDiff<0 &&
						yPosDiff>0)	
				{
					numOfMoves=(moveTo.charAt(1)-position.charAt(1));
					//check any pieces in the middle (position to moveTo)
					for(int i=1;i<numOfMoves;i++)
					{
						tempChess=CMS.getChessPiece((char)(position.charAt(0)+i)+String.valueOf((position.charAt(1)-i)));//wrong formatting
						if(tempChess!=null)
							isBlocked=true;
					}	
				}
				
				if(isBlocked==false)
					return true;
				else
					return false;
			}

		}//end of most outer loop
		return false;
		
	}//end of method

	@Override
	public int getScore() {
		return score;
	}
	
	@Override
	public String toString(){
		if (player.getPlayerId()==1)
			return "B";
		else if (player.getPlayerId()==2)
			return "b";
		else
			return null;
	}

	@Override
	public int getRank() {
		return rank;
	}

}

@@ -90,36 +90,8 @@
 30;%0D
-%0A%09private final int rank=3;%0D
 %0A%0D%0A%09
@@ -3064,66 +3064,7 @@
 %0D%0A%0D%0A
-%09@Override%0D%0A%09public int getRank() %7B%0D%0A%09%09return rank;%0D%0A%09%7D%0D%0A%0D%0A
 %7D%0D%0A

Update Bishop.java