almost working

This commit is contained in:
2025-04-18 18:42:28 +02:00
parent b83726925e
commit 4a58136afe
12 changed files with 232 additions and 16 deletions

View File

@@ -4,6 +4,7 @@ import java.util.List;
import chess.controller.Command;
import chess.controller.CommandExecutor;
import chess.controller.Command.CommandResult;
import chess.controller.commands.GetPieceAtCommand;
import chess.controller.commands.GetPlayerMovesCommand;
import chess.controller.commands.GetAllowedCastlingsCommand;
@@ -50,8 +51,12 @@ public abstract class AI extends GameAdaptator{
}
protected List<Move> getAllowedMoves() {
return getAllowedMoves(this.commandExecutor);
}
protected List<Move> getAllowedMoves(CommandExecutor commandExecutor) {
GetPlayerMovesCommand cmd = new GetPlayerMovesCommand();
sendCommand(cmd);
sendCommand(cmd, commandExecutor);
return cmd.getMoves();
}
@@ -61,8 +66,16 @@ public abstract class AI extends GameAdaptator{
return cmd2.getCastlingResult();
}
protected void sendCommand(Command command) {
this.commandExecutor.executeCommand(command);
protected CommandResult sendCommand(Command command) {
return sendCommand(command, this.commandExecutor);
}
protected CommandResult sendCommand(Command command, CommandExecutor commandExecutor) {
CommandResult result = commandExecutor.executeCommand(command);
if(result == CommandResult.NotAllowed){
System.out.println("eeeeee");
}
return result;
}
}