Search in sources :

Example 11 with ControllerIdPredicate

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

the class VaevictisAsmadiTheDireEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!game.getCombat().getAttackers().contains(this.getSourceId())) {
        return false;
    }
    this.getTargets().clear();
    for (UUID playerId : game.getState().getPlayerList(this.getControllerId())) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        FilterPermanent filter = new FilterPermanent("permanent controlled by " + player.getName());
        filter.add(new ControllerIdPredicate(playerId));
        TargetPermanent target = new TargetPermanent(filter);
        this.addTarget(target);
    }
    return true;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Example 12 with ControllerIdPredicate

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

the class ZilorthaStrengthIncarnateEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    // Change the rule
    FilterCreaturePermanent filter = StaticFilters.FILTER_PERMANENT_CREATURE.copy();
    filter.add(new ControllerIdPredicate(source.getControllerId()));
    game.getState().addPowerInsteadOfToughnessForDamageLethalityFilter(source.getSourceId(), filter);
    return true;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 13 with ControllerIdPredicate

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

the class PermanentsOnTheBattlefieldCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterPermanent localFilter;
    if (onlyControlled) {
        localFilter = filter.copy();
        localFilter.add(new ControllerIdPredicate(source.getControllerId()));
    } else {
        localFilter = filter;
    }
    return ComparisonType.compare(game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game), type, count);
}
Also used : FilterPermanent(mage.filter.FilterPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 14 with ControllerIdPredicate

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

the class CephalidConstableTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
        FilterPermanent filter = new FilterPermanent("permanent" + (event.getAmount() > 1 ? "s" : "") + " damaged player control");
        filter.add(new ControllerIdPredicate(event.getPlayerId()));
        Target target = new TargetPermanent(0, event.getAmount(), filter, false);
        this.getTargets().clear();
        this.getTargets().add(target);
        return true;
    }
    return false;
}
Also used : Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Example 15 with ControllerIdPredicate

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

the class CommandoRaidEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Player opponent = game.getPlayer(event.getPlayerId());
    if (!damageEvent.isCombatDamage() || !event.getSourceId().equals(this.getSourceId()) || opponent == null) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
    filter.add(new ControllerIdPredicate(opponent.getId()));
    this.getTargets().clear();
    this.addTarget(new TargetCreaturePermanent(filter));
    for (Effect effect : this.getAllEffects()) {
        effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
        effect.setValue("damage", event.getAmount());
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

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