You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
965 B
36 lines
965 B
package de.fd.fh;
|
|
|
|
public class FigureRook extends Figure
|
|
{
|
|
@Override
|
|
public boolean moveAllowed(int src, int dst, Figure[] field)
|
|
{
|
|
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;
|
|
}
|
|
|
|
if (rowDiff > 0 && relStep < 0) // diagonal nach rechts oben
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (rowDiff < 0 && relStep > 0) // diagonal nach rechts oben
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (rowDiff < 0 && relStep < 0) // diagonal nach rechts unten
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// TODO: keine Figuren auf dem Weg "überspringen"
|
|
// TODO: falls Figur auf Ziel und keine Figuren auf Weg -> Figur schlagen
|
|
|
|
return super.moveAllowed(src, dst, field);
|
|
}
|
|
}
|