@Override
public boolean apply(Game game, Ability source) {
int numberToTap = source.getManaCostsToPay().getX();
numberToTap = Math.min(game.getBattlefield().getAllActivePermanents().size(), numberToTap);
TargetPermanent target = new TargetPermanent(numberToTap, filter);
if (target.canChoose(source.getControllerId(), game) && target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game)) {
if (!target.getTargets().isEmpty()) {
List<UUID> targets = target.getTargets();
for (UUID targetId : targets) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {