fix console
This commit is contained in:
@@ -6,7 +6,6 @@ package chess;
|
|||||||
import chess.controller.CommandExecutor;
|
import chess.controller.CommandExecutor;
|
||||||
import chess.controller.commands.NewGameCommand;
|
import chess.controller.commands.NewGameCommand;
|
||||||
import chess.model.Game;
|
import chess.model.Game;
|
||||||
import chess.simulator.PromoteTest;
|
|
||||||
import chess.view.consolerender.Console;
|
import chess.view.consolerender.Console;
|
||||||
|
|
||||||
public class ConsoleMain {
|
public class ConsoleMain {
|
||||||
@@ -14,16 +13,9 @@ public class ConsoleMain {
|
|||||||
Game game = new Game();
|
Game game = new Game();
|
||||||
CommandExecutor commandExecutor = new CommandExecutor(game);
|
CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||||
|
|
||||||
PromoteTest promoteTest = new PromoteTest(commandExecutor);
|
|
||||||
commandExecutor.addListener(promoteTest);
|
|
||||||
|
|
||||||
Console console = new Console(commandExecutor);
|
Console console = new Console(commandExecutor);
|
||||||
commandExecutor.addListener(console);
|
commandExecutor.addListener(console);
|
||||||
|
|
||||||
promoteTest.onComplete.connect(() -> {
|
|
||||||
console.setCaptureInput(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
commandExecutor.executeCommand(new NewGameCommand());
|
commandExecutor.executeCommand(new NewGameCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,17 @@ public class Console implements GameListener {
|
|||||||
private final Scanner scanner = new Scanner(System.in);
|
private final Scanner scanner = new Scanner(System.in);
|
||||||
private final CommandExecutor commandExecutor;
|
private final CommandExecutor commandExecutor;
|
||||||
private final ConsolePieceName consolePieceName = new ConsolePieceName();
|
private final ConsolePieceName consolePieceName = new ConsolePieceName();
|
||||||
private boolean captureInput = false;
|
private boolean captureInput;
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
|
|
||||||
public Console(CommandExecutor commandExecutor) {
|
public Console(CommandExecutor commandExecutor, boolean captureInput) {
|
||||||
this.commandExecutor = commandExecutor;
|
this.commandExecutor = commandExecutor;
|
||||||
this.executor = Executors.newSingleThreadExecutor();
|
this.executor = Executors.newSingleThreadExecutor();
|
||||||
|
this.captureInput = captureInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Console(CommandExecutor commandExecutor) {
|
||||||
|
this(commandExecutor, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Piece pieceAt(int x, int y) {
|
private Piece pieceAt(int x, int y) {
|
||||||
|
|||||||
Reference in New Issue
Block a user