almost working
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user