*/
public CommandResult execute(Realm realm) {
if (unit.getCoordinate().equals(coordinate)) {
return new CommandResult(CommandResult.RESULT_OK, "");
}
PathFinder pathFinder = realm.getPathFinder();
if (pathFinder == null) {
return new CommandResult(CommandResult.RESULT_ERROR, "PathFinder for realm is null.");
}
Path path = pathFinder.findPath(unit, coordinate, false);
if (path == null) {
String errorMessage = "There is not any path from unit's current location to target tile\n";
errorMessage = errorMessage + "Units location : " + unit.getCoordinate();
errorMessage = errorMessage + " Target coordinate :" + coordinate;
return new CommandResult(CommandResult.RESULT_ERROR, errorMessage);