Search in sources :

Example 1 with TargetPermanentAmount

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;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) UUID(java.util.UUID) TargetPermanentAmount(mage.target.common.TargetPermanentAmount) TargetAmount(mage.target.TargetAmount)

Aggregations

UUID (java.util.UUID)1 FilterPermanent (mage.filter.FilterPermanent)1 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetAmount (mage.target.TargetAmount)1 TargetPlayer (mage.target.TargetPlayer)1 TargetPermanentAmount (mage.target.common.TargetPermanentAmount)1