Search in sources :

Example 51 with TargetCreaturePermanent

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

the class TheAbyssTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Player player = game.getPlayer(event.getPlayerId());
    if (player != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("nonartifact creature you control");
        filter.add(Predicates.not(CardType.ARTIFACT.getPredicate()));
        filter.add(new ControllerIdPredicate(player.getId()));
        Target target = new TargetCreaturePermanent(filter);
        target.setAbilityController(getControllerId());
        target.setTargetController(player.getId());
        this.getTargets().clear();
        this.getTargets().add(target);
        return true;
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Target(mage.target.Target) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate)

Example 52 with TargetCreaturePermanent

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

the class VesuvanShapeshifterFaceDownEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent copyToCreature = game.getPermanent(source.getSourceId());
    if (copyToCreature != null) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature");
        filter.add(AnotherPredicate.instance);
        TargetCreaturePermanent target = new TargetCreaturePermanent(0, 1, filter, true);
        if (controller != null && controller.chooseTarget(Outcome.BecomeCreature, target, source, game) && !target.getTargets().isEmpty()) {
            Permanent copyFromCreature = game.getPermanentOrLKIBattlefield(target.getFirstTarget());
            if (copyFromCreature != null) {
                game.copyPermanent(Duration.Custom, copyFromCreature, copyToCreature.getId(), source, new VesuvanShapeShifterFaceUpCopyApplier());
                source.getTargets().clear();
                // needed to get effects ready if copy happens in replacment and the copied abilities react of the same event (e.g. turn face up)
                game.getState().processAction(game);
                return true;
            }
        }
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent)

Example 53 with TargetCreaturePermanent

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

the class DetainRestrictionEffect method getText.

@Override
public String getText(Mode mode) {
    if (staticText != null && !staticText.isEmpty()) {
        return staticText;
    }
    StringBuilder sb = new StringBuilder();
    Target target = mode.getTargets().get(0);
    if (target.getMaxNumberOfTargets() == target.getNumberOfTargets()) {
        if (target.getMaxNumberOfTargets() == 1) {
            sb.append("detain target ").append(target.getTargetName());
        } else {
            sb.append("detain ").append(target.getMaxNumberOfTargets()).append(" target ").append(target.getTargetName());
        }
    } else {
        sb.append("detain up to ").append(CardUtil.numberToText(target.getMaxNumberOfTargets())).append(" target ").append(target.getTargetName());
    }
    sb.append(". <i>(Until your next turn, ");
    if (target instanceof TargetCreaturePermanent) {
        sb.append(target.getMaxNumberOfTargets() == 1 ? "that creature" : "those creatures");
    } else {
        sb.append(target.getMaxNumberOfTargets() == 1 ? "that permanent" : "those permanents");
    }
    sb.append(" can't attack or block and ");
    sb.append(target.getMaxNumberOfTargets() == 1 ? "its" : "their");
    sb.append(" activated abilities can't be activated.)</i>");
    return sb.toString();
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Target(mage.target.Target)

Example 54 with TargetCreaturePermanent

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

the class ForcefieldPreventionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        Target target = new TargetCreaturePermanent(1, 1, filter, true);
        if (controller.choose(Outcome.PreventDamage, target, source.getSourceId(), game)) {
            Permanent creature = game.getPermanent(target.getFirstTarget());
            if (creature != null) {
                game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen " + creature.getLogName());
            }
            ContinuousEffect effect = new ForcefieldPreventionEffect();
            effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 55 with TargetCreaturePermanent

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

the class GrimgrinCorpseBornAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getSourceId().equals(this.getSourceId())) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
        UUID defenderId = game.getCombat().getDefenderId(sourceId);
        filter.add(new ControllerIdPredicate(defenderId));
        this.getTargets().clear();
        TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
        this.addTarget(target);
        return true;
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) UUID(java.util.UUID)

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