swing: export game at the end

This commit is contained in:
2025-04-16 18:14:15 +02:00
parent ae55e0d94c
commit 78d48fafc6

View File

@@ -3,9 +3,11 @@ package chess;
import chess.ai.DumbAI;
import chess.controller.CommandExecutor;
import chess.controller.commands.NewGameCommand;
import chess.controller.event.GameAdaptator;
import chess.model.ChessBoard;
import chess.model.Color;
import chess.model.Game;
import chess.pgn.PgnExport;
import chess.view.simplerender.Window;
public class SwingMain {
@@ -22,6 +24,13 @@ public class SwingMain {
DumbAI ai2 = new DumbAI(commandExecutor, Color.White);
commandExecutor.addListener(ai2);
commandExecutor.addListener(new GameAdaptator(){
@Override
public void onGameEnd() {
System.out.println(PgnExport.exportGame(game));
}
});
commandExecutor.executeCommand(new NewGameCommand());
}
}