Commit 00443b1f authored by hosein's avatar hosein

pawn -> canMove added

parent e4c19f83
package pack.Nuts; package pack.Nuts;
public class Pawn { public class Pawn extends Nut {
public Pawn(int id) {
this.id = id;
isAlive = true;
if (id > 0) {
x = 6;
y = id - 1;
} else {
x = 1;
y = 8 + id;
}
}
//
// @Override
// public void move(int[] destination) {
// x = destination[0];
// y = destination[1];
// }
@Override
public boolean canMove(int[] destination) {
if (id > 0) {
if (x == 6 && destination[0] - x == 2 && destination[1] == y) return true;
return destination[0] < x && destination[0] >= x - 1 && destination[1] <= y + 1 && destination[1] >= y - 1;
}else{
return destination[0] > x && destination[0] <= x + 1 && destination[1] <= y + 1 && destination[1] >= y - 1;
}}
@Override
public void changeAlive() {
isAlive = false;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment