This commit is contained in:
@@ -44,6 +44,16 @@ public interface CommandSender {
|
||||
return cmd.getCastlingResult();
|
||||
}
|
||||
|
||||
default boolean canDoCastling() {
|
||||
CastlingResult castlings = getAllowedCastlings();
|
||||
return castlings == CastlingResult.Both || castlings == CastlingResult.Small;
|
||||
}
|
||||
|
||||
default boolean canDoBigCastling() {
|
||||
CastlingResult castlings = getAllowedCastlings();
|
||||
return castlings == CastlingResult.Both || castlings == CastlingResult.Big;
|
||||
}
|
||||
|
||||
default Piece getPieceAt(int x, int y) {
|
||||
return getPieceAt(new Coordinate(x, y));
|
||||
}
|
||||
@@ -77,7 +87,7 @@ public interface CommandSender {
|
||||
}
|
||||
|
||||
default CommandResult sendBigCastling() {
|
||||
return sendCommand(new CastlingCommand(false));
|
||||
return sendCommand(new CastlingCommand(true));
|
||||
}
|
||||
|
||||
default CommandResult sendMove(Move move) {
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CastlingCommand extends PlayerCommand {
|
||||
|
||||
board.setLastMove(this.kingMove);
|
||||
|
||||
outputSystem.onCastling(this.bigCastling);
|
||||
outputSystem.onCastling(this.bigCastling, kingMove, rookMove);
|
||||
|
||||
return CommandResult.Moved;
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ public class AsyncGameDispatcher extends GameDispatcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCastling(boolean bigCastling) {
|
||||
asyncForEachCall((l) -> l.onCastling(bigCastling));
|
||||
public void onCastling(boolean bigCastling, Move kingMove, Move rookMove) {
|
||||
asyncForEachCall((l) -> l.onCastling(bigCastling, kingMove, rookMove));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,7 +60,7 @@ public class EmptyGameDispatcher extends GameDispatcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCastling(boolean bigCastling) {
|
||||
public void onCastling(boolean bigCastling, Move kingMove, Move rookMove) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class GameAdapter implements GameListener {
|
||||
public void onDraw() {}
|
||||
|
||||
@Override
|
||||
public void onCastling(boolean bigCastling) {}
|
||||
public void onCastling(boolean bigCastling, Move kingMove, Move rookMove) {}
|
||||
|
||||
@Override
|
||||
public void onPawnPromoted(PromoteType promotion) {}
|
||||
|
||||
@@ -90,8 +90,10 @@ public interface GameListener {
|
||||
* Invoked when a castling is done
|
||||
*
|
||||
* @param bigCastling if it's queen side castling
|
||||
* @param kingMove the king's move
|
||||
* @param rookMove the rook's move
|
||||
*/
|
||||
void onCastling(boolean bigCastling);
|
||||
void onCastling(boolean bigCastling, Move kingMove, Move rookMove);
|
||||
|
||||
/**
|
||||
* Invoked when a pawn is promoted
|
||||
|
||||
Reference in New Issue
Block a user