Search in sources :

Example 21 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class TopplegeistAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
        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)

Example 22 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class ToothCollectorAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
        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)

Example 23 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class TowerAboveTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getSourceId().equals(this.getSourceId())) {
        this.getTargets().clear();
        TargetCreaturePermanent target = new TargetCreaturePermanent();
        this.addTarget(target);
        return true;
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent)

Example 24 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class UrgeToFeedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    TargetCreaturePermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE, filter, true);
    if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) {
        for (UUID vampireId : target.getTargets()) {
            Permanent vampire = game.getPermanent(vampireId);
            if (vampire != null) {
                vampire.tap(source, game);
                vampire.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
            }
        }
    }
    return true;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) UUID(java.util.UUID)

Example 25 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent 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)

Aggregations

TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)71 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)59 Player (mage.players.Player)49 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)37 Permanent (mage.game.permanent.Permanent)35 UUID (java.util.UUID)25 Target (mage.target.Target)18 FixedTarget (mage.target.targetpointer.FixedTarget)18 Effect (mage.abilities.effects.Effect)8 ContinuousEffect (mage.abilities.effects.ContinuousEffect)7 OneShotEffect (mage.abilities.effects.OneShotEffect)7 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)6 Card (mage.cards.Card)6 DamagedPlayerEvent (mage.game.events.DamagedPlayerEvent)6 ArrayList (java.util.ArrayList)5 Ability (mage.abilities.Ability)5 MageObject (mage.MageObject)4 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)4 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)4 RestrictionEffect (mage.abilities.effects.RestrictionEffect)3