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.
32 lines
693 B
32 lines
693 B
package de.fd.fh;
|
|
|
|
public class Figure
|
|
{
|
|
public static final int fieldLength = 8;
|
|
|
|
public boolean moveAllowed(int src, int dst, int[] field)
|
|
{
|
|
if (src == dst)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (field.length != Figure.fieldLength * Figure.fieldLength)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (dst >= Figure.fieldLength * 7 + 0) // weißer Bauer kein Schritt "runter"
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int stepSize = src / fieldLength - dst / fieldLength;
|
|
if (stepSize > 1) // weißer Bauer nicht mehr als 1 Schritt nach "oben"
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|