finished todo console

This commit is contained in:
Janet-Doe
2025-04-13 17:17:34 +02:00
parent 2271f610e7
commit 2578e8cf6f

View File

@@ -72,8 +72,6 @@ public class Console implements GameListener {
default -> false;
};
} while (!endTurn);
System.out.println(Colors.RED + "Turn ended." + Colors.RESET);
onBoardUpdate();
}
private boolean playerPickedSurrender(Color color) {
@@ -88,12 +86,11 @@ public class Console implements GameListener {
System.out.println("New position: ");
Coordinate end = stringToCoordinate(scanner.nextLine());
Command.CommandResult result = sendCommand(new MoveCommand(new Move(start, end)));
switch (Objects.requireNonNull(result)) {
case Command.CommandResult.Moved:
case Command.CommandResult.ActionNeeded: return true;
default:
return false;
}
return switch (Objects.requireNonNull(result)) {
case Command.CommandResult.Moved, Command.CommandResult.ActionNeeded -> true;
default -> false;
};
} catch (Exception e) {
System.out.println(e.getMessage());
@@ -131,7 +128,6 @@ public class Console implements GameListener {
@Override
public void onKingInCheck() {
System.out.println(Colors.RED + "Check!" + Colors.RESET);
// todo
}
@Override
@@ -141,7 +137,7 @@ public class Console implements GameListener {
@Override
public void onPatSituation() {
// todo
System.out.println("Pat! It's a draw!");
}
@Override
@@ -171,10 +167,10 @@ public class Console implements GameListener {
try {
String promotion = scanner.next();
newPiece = switch (promotion) {
case ("B") -> PromoteCommand.PromoteType.Bishop;
case ("N") -> PromoteCommand.PromoteType.Knight;
case ("Q") -> PromoteCommand.PromoteType.Queen;
case ("R") -> PromoteCommand.PromoteType.Rook;
case "B", "b", "Bishop", "bishop" -> PromoteCommand.PromoteType.Bishop;
case "N", "n", "Knight", "knight" -> PromoteCommand.PromoteType.Knight;
case "Q", "q", "Queen", "queen" -> PromoteCommand.PromoteType.Queen;
case "R", "r", "Rook", "rook" -> PromoteCommand.PromoteType.Rook;
default -> throw new Exception();
};
valid = true;