* @param realm Realm to execute the command
* @return CommandResult
*/
public CommandResult execute(Realm realm) {
if (amount > source.getResourceQuantity(resource)) {
return new CommandResult(CommandResult.RESULT_ERROR, "Not enough resource");
}
if (destination.getRemainingCapacity(resource) < amount) {
amount = destination.getRemainingCapacity(resource);
}
source.setResourceQuantity(resource, source.getResourceQuantity(resource) - amount);
destination.setResourceQuantity(resource, destination.getResourceQuantity(resource) + amount);
return new CommandResult(CommandResult.RESULT_OK, "");
}