* @param realm Realm to execute the command
* @return CommandResult
*/
public CommandResult execute(Realm realm) {
boolean tileHasAllowMovement = false;
Move moveAbility = (Move) unit.getType().getAbility("Move");
if (moveAbility == null) {
return new CommandResult(CommandResult.RESULT_ERROR, "");
}
Tile toTile = realm.getTile(coordinate);
Iterator<TileImprovementType> iterator = toTile.getImprovementsIterator();
while (iterator.hasNext()) {
TileImprovementType tileImprovement = iterator.next();
if (tileImprovement.hasPropertyNamed("AllowMovement")) {
tileHasAllowMovement = true;
break;
}
}
if (!moveAbility.hasTileType(toTile.getType()) && !tileHasAllowMovement) {
return new CommandResult(CommandResult.RESULT_ERROR, "");
}
Vector<Coordinate> adjacentTiles = Utility.getNeighborCoordinates(realm, unit.getCoordinate());
if (!adjacentTiles.contains(coordinate)) {
return new CommandResult(CommandResult.RESULT_ERROR, "");