mirror of
https://github.com/lov3b/Schack.git
synced 2025-01-18 12:50:10 +01:00
Start
This commit is contained in:
parent
4f4a4e2293
commit
0a8f9c7996
@ -7,7 +7,6 @@ import java.util.LinkedHashSet;
|
||||
|
||||
public final class King extends PieceKnownIfMoved {
|
||||
|
||||
|
||||
public King(boolean isWhite, Point startingPosition) throws IOException {
|
||||
super(isWhite, startingPosition);
|
||||
setPieceIcon("King");
|
||||
@ -22,6 +21,36 @@ public final class King extends PieceKnownIfMoved {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addCastlingIfCan(Piece[][] pieces, LinkedHashSet<Point> movable, Point toMove, Point selected) {
|
||||
if (hasMoved) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Vänster
|
||||
for (int kingX = this.position.x - 1; kingX >= 0; kingX--) {
|
||||
if (kingX == 0) {
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
boolean shouldBreak = addMovesIfCan(new Point(kingX, this.position.y), movable, pieces);
|
||||
if (shouldBreak) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Höger
|
||||
for (int kingX = this.position.x + 1; kingX <= 7; kingX++) {
|
||||
boolean shouldBreak = addMovesIfCan(new Point(kingX, this.position.y), movable, pieces);
|
||||
if (shouldBreak) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedHashSet<Point> validMoves(Piece[][] pieces) {
|
||||
LinkedHashSet<Point> movable = new LinkedHashSet<>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user