lots of things

This commit is contained in:
2025-04-01 23:11:41 +02:00
parent 2c6b64fa7d
commit 1b9ff5bdd1
15 changed files with 428 additions and 79 deletions

View File

@@ -0,0 +1,37 @@
package chess.io;
import chess.model.Game;
public class CommandExecutor {
private final Game game;
private final OutputSystem outputSystem;
public CommandExecutor(Game game, OutputSystem outputSystem) {
this.game = game;
this.outputSystem = outputSystem;
}
public CommandResult executeCommand(Command command) {
CommandResult result = command.execute(this.game, this.outputSystem);
if (result == CommandResult.Moved)
alternatePlayers();
return result;
}
private void alternatePlayers() {
this.game.switchPlayerTurn();
this.outputSystem.playerTurn(this.game.getPlayerTurn());
}
public Game getGame() {
return game;
}
public OutputSystem getOutputSystem() {
return outputSystem;
}
}