Search in sources :

Example 26 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class VesuvanDoppelgangerCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null) {
        permanent = game.getPermanentEntering(source.getSourceId());
    }
    final Permanent sourcePermanent = permanent;
    if (controller != null && sourcePermanent != null) {
        Target target = new TargetPermanent(new FilterCreaturePermanent("target creature (you copy from)"));
        target.setRequired(true);
        if (source instanceof SimpleStaticAbility) {
            target = new TargetPermanent(new FilterCreaturePermanent("creature (you copy from)"));
            target.setRequired(false);
            target.setNotTarget(true);
        }
        if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
            controller.choose(Outcome.Copy, target, source.getSourceId(), game);
            Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
            if (copyFromPermanent != null) {
                game.copyPermanent(copyFromPermanent, sourcePermanent.getId(), source, new CopyApplier() {

                    @Override
                    public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
                        blueprint.getColor().setColor(sourcePermanent.getColor(game));
                        blueprint.getAbilities().add(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new VesuvanDoppelgangerCopyEffect(), TargetController.YOU, true, false, rule2));
                        return true;
                    }
                });
                return true;
            }
        }
    }
    return false;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) MageObject(mage.MageObject) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) Target(mage.target.Target) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Game(mage.game.Game) CopyApplier(mage.util.functions.CopyApplier) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Example 27 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class WaveOfTerrorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (permanent == null) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, permanent.getCounters(game).getCount(CounterType.AGE)));
    return new DestroyAllEffect(filter, true).apply(game, source);
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 28 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class EtrataTheSilencerEffect 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 29 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class FinaleOfDevastationEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int xValue = source.getManaCostsToPay().getX();
    if (xValue >= 10) {
        ContinuousEffect effect1 = new BoostControlledEffect(xValue, xValue, Duration.EndOfTurn);
        game.addEffect(effect1, source);
        ContinuousEffect effect2 = new GainAbilityControlledEffect(HasteAbility.getInstance(), Duration.EndOfTurn, new FilterCreaturePermanent());
        game.addEffect(effect2, source);
    }
    return true;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityControlledEffect(mage.abilities.effects.common.continuous.GainAbilityControlledEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) BoostControlledEffect(mage.abilities.effects.common.continuous.BoostControlledEffect)

Example 30 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.

the class GoblinWarCryRestrictionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getFirstTarget());
    if (player == null) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
    filter.add(new ControllerIdPredicate(player.getId()));
    Target target = new TargetPermanent(1, 1, filter, true);
    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
        while (!target.isChosen() && target.canChoose(source.getSourceId(), player.getId(), game) && player.canRespond()) {
            player.chooseTarget(Outcome.DestroyPermanent, target, source, game);
        }
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            game.informPlayers(player.getLogName() + " has chosen " + permanent.getLogName() + " as their only creature able to block this turn");
        }
    }
    game.addEffect(new GoblinWarCryRestrictionEffect(target.getFirstTarget()), source);
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Aggregations

FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)187 Player (mage.players.Player)125 Permanent (mage.game.permanent.Permanent)108 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)83 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)67 UUID (java.util.UUID)55 TargetPermanent (mage.target.TargetPermanent)32 Target (mage.target.Target)31 FilterPermanent (mage.filter.FilterPermanent)27 FixedTarget (mage.target.targetpointer.FixedTarget)25 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)23 ContinuousEffect (mage.abilities.effects.ContinuousEffect)22 MageObject (mage.MageObject)16 PowerPredicate (mage.filter.predicate.mageobject.PowerPredicate)16 OneShotEffect (mage.abilities.effects.OneShotEffect)14 Effect (mage.abilities.effects.Effect)13 Choice (mage.choices.Choice)13 TargetPlayer (mage.target.TargetPlayer)13 Card (mage.cards.Card)12 ChoiceCreatureType (mage.choices.ChoiceCreatureType)12