Super IA (#5)

Reviewed-on: #5
Co-authored-by: Persson-dev <sim16.prib@gmail.com>
Co-committed-by: Persson-dev <sim16.prib@gmail.com>
This commit was merged in pull request #5.
This commit is contained in:
2025-04-30 18:28:01 +00:00
committed by Simon Pribylski
parent ecb0fdc623
commit 3b38e0da1f
26 changed files with 814 additions and 179 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;
}
}