package chessGame;

public class Rook extends ChessPiece {
	private final int score=0;
	
	public Rook(ChessPlayer player, String position) {
		super(player, position);	
	}

	@Override
	public boolean moveIsAvailable(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)
			
			// a1a2 vertical move
			if((int)position.charAt(0)==(int)moveTo.charAt(0))
			{
				// move down
				if((int)position.charAt(1)-(int)moveTo.charAt(1)>0)	
				{
					numOfMoves=((int)position.charAt(1)-(int)moveTo.charAt(1));
					//check any pieces in the middle (position to moveTo)
					for(int i=1;i<numOfMoves;i++)
					{
						tempChess=CMS.getChessPiece(position.charAt(0)+String.valueOf((position.charAt(1)-i)));//wrong formatting
						if(tempChess!=null)
							isBlocked=true;
					}	
				}
				// move up
				if((int)position.charAt(1)-(int)moveTo.charAt(1)<0)
				{
					numOfMoves=(int)moveTo.charAt(1)-(int)position.charAt(1);
					//check any pieces in the middle (position to moveTo)
					for(int i=1;i<numOfMoves;i++)
					{
						tempChess=CMS.getChessPiece(position.charAt(0)+String.valueOf((position.charAt(1)+i)));//wrong formatting
						if(tempChess!=null)
							isBlocked=true;
					}	
				}					
			}
			// a1b2 horizontal move
			if((int)position.charAt(1)==(int)moveTo.charAt(1))
			{
				// move left
				if((int)position.charAt(0)-(int)moveTo.charAt(0)>0)	
				{
					numOfMoves=((int)position.charAt(0)-(int)moveTo.charAt(0));
					//check any pieces in the middle (position to moveTo)
					for(int i=1;i<numOfMoves;i++)
					{
						tempChess=CMS.getChessPiece((char)((int)position.charAt(0)-i)+Integer.toString(position.charAt(1)));//wrong formatting
						if(tempChess!=null)
							isBlocked=true;
					}	
				}
				// move right
				if((int)position.charAt(0)-(int)moveTo.charAt(0)<0)
				{
					numOfMoves=(int)moveTo.charAt(0)-(int)position.charAt(0);
					//check any pieces in the middle (position to moveTo)
					for(int i=1;i<numOfMoves;i++)
					{
						tempChess=CMS.getChessPiece((char)((int)position.charAt(0)+i)+Integer.toString(position.charAt(1)));//wrong formatting
						if(tempChess!=null)
							isBlocked=true;
					}	
				}					
			}
			if(isBlocked==false)
				return true;
			else
				return false;
			
		}//end of most outer loop
		else
			return false;

	}//end of method

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

}

@@ -1670,37 +1670,107 @@
 %0D%0A%09%09%09%09%09%7D%09%0D%0A%09%09%09%09%7D
-%09%09%09%09%09
+%0D%0A%09%09%09%09if(isBlocked==false)%0D%0A%09%09%09%09%09return true;%0D%0A%09%09%09%09else%0D%0A%09%09%09%09%09return false;
 %0D%0A%09%09%09%7D%0D%0A%09%09%09// a1
@@ -2742,21 +2742,11 @@
 %09%09%09%7D
-%09%09%09%09%09%0D%0A%09%09%09%7D
 %0D%0A
+%09
 %09%09%09i
@@ -2766,24 +2766,25 @@
 false)%0D%0A%09%09%09%09
+%09
 return true;
@@ -2788,22 +2788,24 @@
 ue;%0D%0A%09%09%09
+%09
 else%0D%0A
+%09
 %09%09%09%09retu
@@ -2815,16 +2815,22 @@
 false;%0D%0A
+%09%09%09%7D%0D%0A
 %09%09%09%0D%0A%09%09%7D

Update Rook.java