almost working
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package chess.controller.event;
|
||||
|
||||
import chess.controller.commands.PromoteCommand.PromoteType;
|
||||
import chess.model.Color;
|
||||
import chess.model.Coordinate;
|
||||
import chess.model.Move;
|
||||
@@ -45,4 +46,10 @@ public abstract class GameAdaptator implements GameListener {
|
||||
@Override
|
||||
public void onDraw() {}
|
||||
|
||||
@Override
|
||||
public void onCastling(boolean bigCastling) {}
|
||||
|
||||
@Override
|
||||
public void onPawnPromoted(PromoteType promotion, Color player) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import chess.controller.commands.PromoteCommand.PromoteType;
|
||||
import chess.model.Color;
|
||||
import chess.model.Coordinate;
|
||||
import chess.model.Move;
|
||||
@@ -93,6 +94,16 @@ public class GameDispatcher implements GameListener {
|
||||
asyncForEachCall((l) -> l.onDraw());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCastling(boolean bigCastling) {
|
||||
asyncForEachCall((l) -> l.onCastling(bigCastling));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPawnPromoted(PromoteType promotion, Color player) {
|
||||
asyncForEachCall((l) -> l.onPawnPromoted(promotion, player));
|
||||
}
|
||||
|
||||
public void stopService() {
|
||||
this.executor.shutdown();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package chess.controller.event;
|
||||
|
||||
import chess.controller.commands.PromoteCommand.PromoteType;
|
||||
import chess.model.Color;
|
||||
import chess.model.Coordinate;
|
||||
import chess.model.Move;
|
||||
@@ -15,7 +16,7 @@ public interface GameListener {
|
||||
* Invoked when a draw occurs (same position is repeated three times)
|
||||
*/
|
||||
void onDraw();
|
||||
|
||||
|
||||
/**
|
||||
* Invoked when the game has ended (by a win or a draw)
|
||||
*/
|
||||
@@ -25,7 +26,7 @@ public interface GameListener {
|
||||
* Invoked when the game has started
|
||||
*/
|
||||
void onGameStart();
|
||||
|
||||
|
||||
/**
|
||||
* Invoked when a king is in check
|
||||
*/
|
||||
@@ -35,47 +36,68 @@ public interface GameListener {
|
||||
* Invoked when a checkmate occurs
|
||||
*/
|
||||
void onKingInMat();
|
||||
|
||||
|
||||
/**
|
||||
* Invoked when a valid move on the board occurs
|
||||
*
|
||||
* @param move the move to be processed
|
||||
*/
|
||||
void onMove(Move move);
|
||||
|
||||
/**
|
||||
* Invoked when a sent move is not allowed
|
||||
*
|
||||
* @param move the move to be processed
|
||||
*/
|
||||
void onMoveNotAllowed(Move move);
|
||||
|
||||
|
||||
/**
|
||||
* Invoked when a pat situation occurs
|
||||
*/
|
||||
void onPatSituation();
|
||||
|
||||
|
||||
/**
|
||||
* Invoked when it's the player turn
|
||||
* @param color the color of the player who should play
|
||||
*
|
||||
* @param color the color of the player who should play
|
||||
* @param undone true if it's a result of an undo command
|
||||
*/
|
||||
void onPlayerTurn(Color color, boolean undone);
|
||||
|
||||
|
||||
/**
|
||||
* Invoked when a pawn should be promoted
|
||||
*
|
||||
* @param pieceCoords the coordinates of the pawn
|
||||
*/
|
||||
void onPromotePawn(Coordinate pieceCoords);
|
||||
|
||||
|
||||
/**
|
||||
* Invoked when a players surrenders
|
||||
*
|
||||
* @param coward the player who gave up
|
||||
*/
|
||||
void onSurrender(Color coward);
|
||||
|
||||
|
||||
/**
|
||||
* Invoked when a player wins (by checkmate or if the other one surrenders)
|
||||
*
|
||||
* @param winner
|
||||
*/
|
||||
void onWin(Color winner);
|
||||
|
||||
/**
|
||||
* Invoked when a castling is done
|
||||
*
|
||||
* @param bigCastling if it's queen side castling
|
||||
*/
|
||||
void onCastling(boolean bigCastling);
|
||||
|
||||
/**
|
||||
* Invoked when a pawn is promoted
|
||||
*
|
||||
* @param promotion the type of promotion
|
||||
* @param player the player who promoted the pawns
|
||||
*/
|
||||
void onPawnPromoted(PromoteType promotion, Color player);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user