37 lines
841 B
Java
37 lines
841 B
Java
package chess.ai.actions;
|
|
|
|
import chess.controller.CommandExecutor;
|
|
import chess.controller.CommandSender;
|
|
import chess.controller.commands.UndoCommand;
|
|
|
|
/**
|
|
* Abstract class, manage the possible actions of a bot.
|
|
*/
|
|
public abstract class AIAction implements CommandSender {
|
|
|
|
private final CommandExecutor commandExecutor;
|
|
|
|
public AIAction(CommandExecutor commandExecutor) {
|
|
this.commandExecutor = commandExecutor;
|
|
}
|
|
|
|
@Override
|
|
public CommandExecutor getCommandExecutor() {
|
|
return this.commandExecutor;
|
|
}
|
|
|
|
public void undoAction(CommandExecutor commandExecutor) {
|
|
sendCommand(new UndoCommand(), commandExecutor);
|
|
}
|
|
|
|
public void undoAction() {
|
|
undoAction(this.commandExecutor);
|
|
}
|
|
|
|
public void applyAction() {
|
|
applyAction(this.commandExecutor);
|
|
}
|
|
|
|
public abstract void applyAction(CommandExecutor commandExecutor);
|
|
}
|