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