|
@ -5,22 +5,25 @@ public class FigureRook extends Figure |
|
|
@Override |
|
|
@Override |
|
|
public boolean moveAllowed(int src, int dst, int[] field) |
|
|
public boolean moveAllowed(int src, int dst, int[] field) |
|
|
{ |
|
|
{ |
|
|
if (src / fieldLength - dst / fieldLength > 0 && src % fieldLength - dst % fieldLength > 0) // diagonal nach links oben |
|
|
|
|
|
|
|
|
int rowDiff = src / fieldLength - dst / fieldLength; // hoch/runter |
|
|
|
|
|
int relStep = src % fieldLength - dst % fieldLength; // links//rechts |
|
|
|
|
|
|
|
|
|
|
|
if (rowDiff > 0 && relStep > 0) // diagonal nach links oben |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (src / fieldLength - dst / fieldLength > 0 && src % fieldLength - dst % fieldLength < 0) // diagonal nach rechts oben |
|
|
|
|
|
|
|
|
if (rowDiff > 0 && relStep < 0) // diagonal nach rechts oben |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (src / fieldLength - dst / fieldLength < 0 && src % fieldLength - dst % fieldLength > 0) // diagonal nach rechts oben |
|
|
|
|
|
|
|
|
if (rowDiff < 0 && relStep > 0) // diagonal nach rechts oben |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (src / fieldLength - dst / fieldLength < 0 && src % fieldLength - dst % fieldLength < 0) // diagonal nach rechts unten |
|
|
|
|
|
|
|
|
if (rowDiff < 0 && relStep < 0) // diagonal nach rechts unten |
|
|
{ |
|
|
{ |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|