Search in sources :

Example 31 with ControllerIdPredicate

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

the class AshiokSculptorOfFearsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterPermanent filter = new FilterCreaturePermanent();
    filter.add(new ControllerIdPredicate(source.getFirstTarget()));
    new GainControlAllEffect(Duration.Custom, filter).apply(game, source);
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) GainControlAllEffect(mage.abilities.effects.common.continuous.GainControlAllEffect)

Example 32 with ControllerIdPredicate

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

the class AshlingTheExtinguisherTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
        Player opponent = game.getPlayer(event.getPlayerId());
        if (opponent != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
            filter.add(new ControllerIdPredicate(opponent.getId()));
            this.getTargets().clear();
            this.addTarget(new TargetCreaturePermanent(filter));
            return true;
        }
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 33 with ControllerIdPredicate

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

the class BlindZealotTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player opponent = game.getPlayer(event.getPlayerId());
    if (opponent == null || !event.getSourceId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
    filter.add(new ControllerIdPredicate(opponent.getId()));
    this.getTargets().clear();
    this.addTarget(new TargetCreaturePermanent(filter));
    return true;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DamagedEvent(mage.game.events.DamagedEvent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 34 with ControllerIdPredicate

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

the class CausticWaspsTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getSourceId().equals(this.sourceId) && ((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) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Example 35 with ControllerIdPredicate

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

the class CyclopsGladiatorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
    if (defenderId != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
        filter.add(new ControllerIdPredicate(defenderId));
        TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
        Player player = game.getPlayer(source.getControllerId());
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
            if (player != null && player.chooseTarget(Outcome.Detriment, target, source, game)) {
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                Permanent cyclops = game.getPermanent(source.getSourceId());
                if (permanent != null && cyclops != null) {
                    permanent.damage(cyclops.getPower().getValue(), cyclops.getId(), source, game, false, true);
                    cyclops.damage(permanent.getPower().getValue(), permanent.getId(), source, game, false, true);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) 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