swing: export game at the end
This commit is contained in:
@@ -3,9 +3,11 @@ package chess;
|
|||||||
import chess.ai.DumbAI;
|
import chess.ai.DumbAI;
|
||||||
import chess.controller.CommandExecutor;
|
import chess.controller.CommandExecutor;
|
||||||
import chess.controller.commands.NewGameCommand;
|
import chess.controller.commands.NewGameCommand;
|
||||||
|
import chess.controller.event.GameAdaptator;
|
||||||
import chess.model.ChessBoard;
|
import chess.model.ChessBoard;
|
||||||
import chess.model.Color;
|
import chess.model.Color;
|
||||||
import chess.model.Game;
|
import chess.model.Game;
|
||||||
|
import chess.pgn.PgnExport;
|
||||||
import chess.view.simplerender.Window;
|
import chess.view.simplerender.Window;
|
||||||
|
|
||||||
public class SwingMain {
|
public class SwingMain {
|
||||||
@@ -22,6 +24,13 @@ public class SwingMain {
|
|||||||
DumbAI ai2 = new DumbAI(commandExecutor, Color.White);
|
DumbAI ai2 = new DumbAI(commandExecutor, Color.White);
|
||||||
commandExecutor.addListener(ai2);
|
commandExecutor.addListener(ai2);
|
||||||
|
|
||||||
|
commandExecutor.addListener(new GameAdaptator(){
|
||||||
|
@Override
|
||||||
|
public void onGameEnd() {
|
||||||
|
System.out.println(PgnExport.exportGame(game));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
commandExecutor.executeCommand(new NewGameCommand());
|
commandExecutor.executeCommand(new NewGameCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user