mirror of
https://github.com/lov3b/Schack.git
synced 2025-01-18 21:00:11 +01:00
bättre castling igen
This commit is contained in:
parent
d5244cea94
commit
76be123a54
@ -13,7 +13,7 @@ public final class King extends PieceKnownIfMoved {
|
|||||||
|
|
||||||
private ArrayList<Point> getCastlingIfPossible(Piece[][] pieces) {
|
private ArrayList<Point> getCastlingIfPossible(Piece[][] pieces) {
|
||||||
ArrayList<Point> possibleCastling = new ArrayList<>();
|
ArrayList<Point> possibleCastling = new ArrayList<>();
|
||||||
if (isMoved()) {
|
if (this.isMoved()) {
|
||||||
return possibleCastling;
|
return possibleCastling;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,11 +25,9 @@ public final class King extends PieceKnownIfMoved {
|
|||||||
if (loopX == 0 && nothingInBetween) {
|
if (loopX == 0 && nothingInBetween) {
|
||||||
|
|
||||||
// Check så att man bara kan göra rockad ifall tornet inte rört sig
|
// Check så att man bara kan göra rockad ifall tornet inte rört sig
|
||||||
Piece p = pieces[loopX][this.position.y];
|
Piece possibleRook = pieces[loopX][this.position.y];
|
||||||
if (p != null) {
|
if (possibleRook != null && !possibleRook.isMoved()) {
|
||||||
if (!p.isMoved()) {
|
possibleCastling.add(new Point(2, this.position.y));
|
||||||
possibleCastling.add(new Point(2, this.position.y));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,11 +44,9 @@ public final class King extends PieceKnownIfMoved {
|
|||||||
// Kolla ifall vi kollar tornet och inget är emellan
|
// Kolla ifall vi kollar tornet och inget är emellan
|
||||||
if (loopX == 7 && nothingInBetween) {
|
if (loopX == 7 && nothingInBetween) {
|
||||||
// Check så att man bara kan göra rockad ifall tornet inte rört sig
|
// Check så att man bara kan göra rockad ifall tornet inte rört sig
|
||||||
Piece p = pieces[loopX][this.position.y];
|
Piece possibleRook = pieces[loopX][this.position.y];
|
||||||
if (p != null) {
|
if (possibleRook != null && !possibleRook.isMoved()) {
|
||||||
if (!p.isMoved()) {
|
possibleCastling.add(new Point(6, this.position.y));
|
||||||
possibleCastling.add(new Point(6, this.position.y));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +78,7 @@ public final class King extends PieceKnownIfMoved {
|
|||||||
@Override
|
@Override
|
||||||
public void move(Piece[][] pieces, Point toMove) {
|
public void move(Piece[][] pieces, Point toMove) {
|
||||||
if (Math.abs(position.x - toMove.x) == 2) {
|
if (Math.abs(position.x - toMove.x) == 2) {
|
||||||
final boolean goToLeftSide = (toMove.x < 5) ? true : false;
|
final boolean goToLeftSide = toMove.x < 5;
|
||||||
castle(pieces, goToLeftSide);
|
castle(pieces, goToLeftSide);
|
||||||
} else {
|
} else {
|
||||||
super.move(pieces, toMove);
|
super.move(pieces, toMove);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user