Search in sources :

Example 76 with TargetPermanent

use of mage.target.TargetPermanent in project mage by magefree.

the class MindlinkMechApplier method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getSourceId().equals(getSourceId()) || !MindlinkMechWatcher.checkVehicle(this, game)) {
        return false;
    }
    this.getTargets().clear();
    this.addTarget(new TargetPermanent(MindlinkMechWatcher.makeFilter(this, game)));
    return true;
}
Also used : TargetPermanent(mage.target.TargetPermanent)

Example 77 with TargetPermanent

use of mage.target.TargetPermanent in project mage by magefree.

the class NettlevineBlightEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent nettlevineBlight = game.getPermanent(source.getSourceId());
    Player newController = null;
    if (controller != null && nettlevineBlight != null) {
        Permanent enchantedPermanent = game.getPermanent(nettlevineBlight.getAttachedTo());
        if (enchantedPermanent != null) {
            newController = game.getPlayer(enchantedPermanent.getControllerId());
            enchantedPermanent.sacrifice(source, game);
        }
        if (newController != null) {
            FilterPermanent filter = new FilterPermanent("creature or land permanent you control");
            filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.LAND.getPredicate()));
            filter.add(new ControllerIdPredicate(newController.getId()));
            filter.add(new CanBeEnchantedByPredicate(nettlevineBlight));
            Target target = new TargetPermanent(filter);
            target.setNotTarget(true);
            if (target.canChoose(source.getSourceId(), newController.getId(), game) && newController.choose(outcome, target, source.getSourceId(), game)) {
                Permanent chosenPermanent = game.getPermanent(target.getFirstTarget());
                if (chosenPermanent != null) {
                    Card nettlevineBlightCard = game.getCard(source.getSourceId());
                    if (nettlevineBlightCard != null) {
                        game.getState().setValue("attachTo:" + nettlevineBlight.getId(), chosenPermanent);
                        chosenPermanent.addAttachment(nettlevineBlight.getId(), source, game);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) CanBeEnchantedByPredicate(mage.filter.predicate.permanent.CanBeEnchantedByPredicate) Card(mage.cards.Card)

Example 78 with TargetPermanent

use of mage.target.TargetPermanent in project mage by magefree.

the class SakashimasWillCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetPermanent target = new TargetControlledCreaturePermanent();
    target.setNotTarget(true);
    if (!target.canChoose(source.getSourceId(), player.getId(), game)) {
        return false;
    }
    player.choose(outcome, target, source.getSourceId(), game);
    Permanent chosenCreature = game.getPermanent(target.getFirstTarget());
    if (chosenCreature == null) {
        return false;
    }
    for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, player.getId(), source.getSourceId(), game)) {
        if (permanent == null || permanent.getId().equals(chosenCreature.getId())) {
            continue;
        }
        game.copyPermanent(Duration.EndOfTurn, chosenCreature, permanent.getId(), source, new EmptyCopyApplier());
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) TargetPermanent(mage.target.TargetPermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 79 with TargetPermanent

use of mage.target.TargetPermanent in project mage by magefree.

the class DeadlyVanityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    TargetPermanent target = new TargetCreatureOrPlaneswalker();
    target.setNotTarget(true);
    controller.choose(outcome, target, source.getId(), game);
    FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent();
    UUID targetId = target.getFirstTarget();
    if (targetId != null) {
        filter.add(Predicates.not(new PermanentIdPredicate(targetId)));
    }
    return new DestroyAllEffect(filter).apply(game, source);
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) TargetCreatureOrPlaneswalker(mage.target.common.TargetCreatureOrPlaneswalker) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 80 with TargetPermanent

use of mage.target.TargetPermanent in project mage by magefree.

the class StranglingGraspEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = source.getSourcePermanentOrLKI(game);
    if (sourcePermanent == null) {
        return false;
    }
    Permanent attachedTo = game.getPermanentOrLKIBattlefield(sourcePermanent.getAttachedTo());
    if (attachedTo == null) {
        return false;
    }
    Player player = game.getPlayer(attachedTo.getControllerId());
    if (player == null) {
        return false;
    }
    TargetPermanent target = new TargetPermanent(filter);
    target.setNotTarget(true);
    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
        player.choose(outcome, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            permanent.sacrifice(source, game);
        }
    }
    player.loseLife(1, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) FilterCreatureOrPlaneswalkerPermanent(mage.filter.common.FilterCreatureOrPlaneswalkerPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) TargetPermanent(mage.target.TargetPermanent)

Aggregations

TargetPermanent (mage.target.TargetPermanent)222 Player (mage.players.Player)173 Permanent (mage.game.permanent.Permanent)167 FilterPermanent (mage.filter.FilterPermanent)108 UUID (java.util.UUID)65 Target (mage.target.Target)58 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)47 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)36 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)32 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)24 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)19 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)19 FixedTarget (mage.target.targetpointer.FixedTarget)19 MageObject (mage.MageObject)18 Ability (mage.abilities.Ability)18 Card (mage.cards.Card)17 ArrayList (java.util.ArrayList)15 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)14 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)14 OneShotEffect (mage.abilities.effects.OneShotEffect)13