Search in sources :

Example 11 with FilterCreaturePermanent

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

the class ValiantEndeavorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    List<Integer> results = controller.rollDice(outcome, source, game, 6, 2, 0);
    int firstResult = results.get(0);
    int secondResult = results.get(1);
    int first, second;
    if (firstResult != secondResult && controller.chooseUse(outcome, "Destroy each creature with power greater than or equal to your choice", "The other number will be the amount of 2/2 white Knight tokens with vigilance.", "" + firstResult, "" + secondResult, source, game)) {
        first = firstResult;
        second = secondResult;
    } else {
        first = secondResult;
        second = firstResult;
    }
    final FilterCreaturePermanent filter = new FilterCreaturePermanent(String.format("creatures with power greater than or equal to %s", first));
    filter.add(new PowerPredicate(ComparisonType.MORE_THAN, first - 1));
    Effect wrathEffect = new DestroyAllEffect(filter);
    wrathEffect.apply(game, source);
    new KnightToken().putOntoBattlefield(second, game, source, source.getControllerId());
    return true;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) PowerPredicate(mage.filter.predicate.mageobject.PowerPredicate) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect) KnightToken(mage.game.permanent.token.KnightToken) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 12 with FilterCreaturePermanent

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

the class WallOfStolenIdentityCopyEffect 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) {
        return false;
    }
    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)) {
        return false;
    }
    controller.choose(Outcome.Copy, target, source.getSourceId(), game);
    Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
    if (copyFromPermanent == null) {
        return false;
    }
    game.copyPermanent(copyFromPermanent, sourcePermanent.getId(), source, new CopyApplier() {

        @Override
        public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
            blueprint.addSubType(SubType.WALL);
            blueprint.getAbilities().add(DefenderAbility.getInstance());
            return true;
        }
    });
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new TapTargetEffect(), false, "tap the copied creature " + "and it doesn't untap during its controller's untap step for as long as you control {this}");
    ability.addEffect(new DontUntapInControllersUntapStepTargetEffect(Duration.WhileControlled));
    ability.getEffects().setTargetPointer(new FixedTarget(copyFromPermanent, game));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DefenderAbility(mage.abilities.keyword.DefenderAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) MageObject(mage.MageObject) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Game(mage.game.Game) CopyApplier(mage.util.functions.CopyApplier) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TapTargetEffect(mage.abilities.effects.common.TapTargetEffect) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) DontUntapInControllersUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersUntapStepTargetEffect)

Example 13 with FilterCreaturePermanent

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

the class WallOfVaporEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) {
        DamageEvent damageEvent = (DamageEvent) event;
        if (event.getTargetId().equals(source.getSourceId())) {
            Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new BlockedByIdPredicate(source.getSourceId()));
            if (permanent != null && filter.match(permanent, game)) {
                return true;
            }
        }
    }
    return false;
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DamageEvent(mage.game.events.DamageEvent) BlockedByIdPredicate(mage.filter.predicate.permanent.BlockedByIdPredicate)

Example 14 with FilterCreaturePermanent

use of mage.filter.common.FilterCreaturePermanent 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 15 with FilterCreaturePermanent

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

the class AlphaBrawlEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID targetId = source.getFirstTarget();
    FilterCreaturePermanent filter = new FilterCreaturePermanent("each other creature that player controls");
    filter.add(Predicates.not(new PermanentIdPredicate(targetId)));
    Permanent creature = game.getPermanent(targetId);
    if (creature != null) {
        Player player = game.getPlayer(creature.getControllerId());
        if (player != null) {
            int power = creature.getPower().getValue();
            for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
                perm.damage(power, creature.getId(), source, game, false, true);
            }
            for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
                creature.damage(perm.getPower().getValue(), perm.getId(), source, game, false, true);
            }
            return true;
        }
    }
    return false;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) UUID(java.util.UUID)

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