Search in sources :

Example 66 with ControllerIdPredicate

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

the class InciteWarMustAttackEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
    if (player != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(player.getId()));
        RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : RequirementEffect(mage.abilities.effects.RequirementEffect) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) AttacksIfAbleAllEffect(mage.abilities.effects.common.combat.AttacksIfAbleAllEffect)

Example 67 with ControllerIdPredicate

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

the class KeldonFirebombersEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    List<Permanent> landsToSacrifice = new ArrayList<>();
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            int amount = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size() - 3;
            if (amount > 0) {
                FilterLandPermanent playerFilter = filter.copy();
                playerFilter.add(new ControllerIdPredicate(playerId));
                Target target = new TargetLandPermanent(amount, amount, playerFilter, true);
                player.choose(outcome.Sacrifice, target, source.getSourceId(), game);
                for (UUID landId : target.getTargets()) {
                    Permanent land = game.getPermanent(landId);
                    if (land != null) {
                        landsToSacrifice.add(land);
                    }
                }
            }
        }
    }
    for (Permanent land : landsToSacrifice) {
        land.sacrifice(source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetLandPermanent(mage.target.common.TargetLandPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ArrayList(java.util.ArrayList) TargetLandPermanent(mage.target.common.TargetLandPermanent) UUID(java.util.UUID)

Example 68 with ControllerIdPredicate

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

the class LatullasOrdersTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
    if (event.getSourceId().equals(enchantment.getAttachedTo()) && ((DamagedPlayerEvent) event).isCombatDamage()) {
        Player player = game.getPlayer(event.getTargetId());
        if (player != null) {
            FilterPermanent filter = new FilterPermanent("an artifact controlled by " + player.getLogName());
            filter.add(CardType.ARTIFACT.getPredicate());
            filter.add(new ControllerIdPredicate(event.getTargetId()));
            this.getTargets().clear();
            this.addTarget(new TargetPermanent(filter));
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Example 69 with ControllerIdPredicate

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

the class LavalancheEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayerOrPlaneswalkerController(source.getFirstTarget());
    if (targetPlayer == null) {
        return false;
    }
    targetPlayer.damage(amount.calculate(game, source, this), source.getSourceId(), source, game);
    FilterPermanent filter = new FilterPermanent("and each creature that player or that planeswalker's controller controls");
    filter.add(CardType.CREATURE.getPredicate());
    filter.add(new ControllerIdPredicate(targetPlayer.getId()));
    List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
    for (Permanent permanent : permanents) {
        permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true);
    }
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 70 with ControllerIdPredicate

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

the class LordOfShatterskullPassEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
    if (defenderId != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(defenderId));
        List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
        for (Permanent permanent : permanents) {
            permanent.damage(6, source.getSourceId(), source, game, false, true);
        }
        return true;
    }
    return false;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) UUID(java.util.UUID)

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