Search in sources :

Example 81 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class TorrentOfSoulsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetedPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
    if (targetedPlayer != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(targetedPlayer.getId()));
        ContinuousEffect boostEffect = new BoostAllEffect(2, 0, Duration.EndOfTurn, filter, true);
        ContinuousEffect gainAbilityEffect = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filter);
        game.addEffect(boostEffect, source);
        game.addEffect(gainAbilityEffect, source);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect) GainAbilityAllEffect(mage.abilities.effects.common.continuous.GainAbilityAllEffect)

Example 82 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class ZndrspltsJudgmentEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
    choice.chooseFriendOrFoe(controller, source, game);
    for (Player player : choice.getFriends()) {
        if (player == null) {
            continue;
        }
        FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
        filter.add(new ControllerIdPredicate(player.getId()));
        TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
        if (!player.choose(Outcome.Copy, target, source.getSourceId(), game)) {
            continue;
        }
        Effect effect = new CreateTokenCopyTargetEffect(player.getId());
        effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
        effect.apply(game, source);
    }
    for (Player player : choice.getFoes()) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
        filter.add(new ControllerIdPredicate(player.getId()));
        TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
        if (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
            continue;
        }
        Effect effect = new ReturnToHandTargetEffect();
        effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
        effect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ChooseFriendsAndFoes(mage.choices.ChooseFriendsAndFoes) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect)

Example 83 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class OpponentControlsPermanentCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean conditionApplies = false;
    for (UUID opponentId : game.getOpponents(source.getControllerId())) {
        FilterPermanent localFilter = filter.copy();
        localFilter.add(new ControllerIdPredicate(opponentId));
        if (ComparisonType.compare(game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game), type, this.count)) {
            conditionApplies = true;
            break;
        }
    }
    return conditionApplies;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) UUID(java.util.UUID)

Example 84 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class EmissaryOfDespairCount method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    if (effect.getTargetPointer().getFirst(game, sourceAbility) == null) {
        return 0;
    }
    FilterArtifactPermanent filter = new FilterArtifactPermanent();
    filter.add(new ControllerIdPredicate(effect.getTargetPointer().getFirst(game, sourceAbility)));
    return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
Also used : FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 85 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class EmberGaleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(source.getFirstTarget());
    if (targetPlayer != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(targetPlayer.getId()));
        RestrictionEffect effect = new CantBlockAllEffect(filter, Duration.EndOfTurn);
        game.addEffect(effect, source);
        FilterPermanent filter2 = new FilterPermanent();
        filter2.add(new ControllerIdPredicate(targetPlayer.getId()));
        filter2.add(Predicates.or(new ColorPredicate(ObjectColor.WHITE), new ColorPredicate(ObjectColor.BLUE)));
        filter2.add(CardType.CREATURE.getPredicate());
        for (Permanent creature : game.getBattlefield().getAllActivePermanents(filter2, targetPlayer.getId(), game)) {
            creature.damage(1, source.getSourceId(), source, game, false, true);
        }
        return true;
    }
    return false;
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) CantBlockAllEffect(mage.abilities.effects.common.combat.CantBlockAllEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) RestrictionEffect(mage.abilities.effects.RestrictionEffect)

Aggregations

ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)153 Player (mage.players.Player)105 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)87 Permanent (mage.game.permanent.Permanent)70 UUID (java.util.UUID)53 TargetPermanent (mage.target.TargetPermanent)53 FilterPermanent (mage.filter.FilterPermanent)51 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)41 Target (mage.target.Target)29 FixedTarget (mage.target.targetpointer.FixedTarget)21 TargetPlayer (mage.target.TargetPlayer)16 ContinuousEffect (mage.abilities.effects.ContinuousEffect)15 Effect (mage.abilities.effects.Effect)14 OneShotEffect (mage.abilities.effects.OneShotEffect)13 FilterLandPermanent (mage.filter.common.FilterLandPermanent)13 DamagedPlayerEvent (mage.game.events.DamagedPlayerEvent)11 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)9 FilterNonlandPermanent (mage.filter.common.FilterNonlandPermanent)9 MageObject (mage.MageObject)8 HashSet (java.util.HashSet)7