use of mage.target.common.TargetPermanentAmount in project mage by magefree.
the class InvokeJusticeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller == null || player == null) {
return false;
}
FilterPermanent filter = new FilterPermanent("creatures and/or Vehicles controlled by " + player.getName());
filter.add(new ControllerIdPredicate(player.getId()));
if (!game.getBattlefield().contains(filter, source, game, 1)) {
return false;
}
TargetAmount target = new TargetPermanentAmount(4, filter);
target.setNotTarget(true);
controller.choose(outcome, target, source.getSourceId(), game);
for (UUID targetId : target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(target.getTargetAmount(targetId)), source, game);
}
}
return true;
}
Aggregations