Search in sources :

Example 1 with DestroyAllEffect

use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.

the class PerniciousDeedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterPermanent filter = new FilterPermanent("artifacts, creatures, and enchantments");
    filter.add(Predicates.or(CardType.ARTIFACT.getPredicate(), CardType.CREATURE.getPredicate(), CardType.ENCHANTMENT.getPredicate()));
    filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
    return new DestroyAllEffect(filter).apply(game, source);
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 2 with DestroyAllEffect

use of mage.abilities.effects.common.DestroyAllEffect 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 3 with DestroyAllEffect

use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.

the class ZzzyxassAbyssEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        List<String> permanentNames = new ArrayList<>();
        FilterPermanent filter = new FilterNonlandPermanent();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), game)) {
            permanentNames.add(permanent.getName());
        }
        if (permanentNames.isEmpty()) {
            return true;
        }
        Collections.sort(permanentNames);
        filter.add(new NamePredicate(permanentNames.get(0)));
        return new DestroyAllEffect(filter).apply(game, source);
    }
    return false;
}
Also used : Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) FilterPermanent(mage.filter.FilterPermanent) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) ArrayList(java.util.ArrayList) FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 4 with DestroyAllEffect

use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.

the class CelestialKirinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
    if (spell != null) {
        int cmc = spell.getManaValue();
        FilterPermanent filter = new FilterPermanent();
        filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));
        return new DestroyAllEffect(filter).apply(game, source);
    }
    return false;
}
Also used : ManaValuePredicate(mage.filter.predicate.mageobject.ManaValuePredicate) FilterPermanent(mage.filter.FilterPermanent) Spell(mage.game.stack.Spell) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Example 5 with DestroyAllEffect

use of mage.abilities.effects.common.DestroyAllEffect in project mage by magefree.

the class CoercivePortalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // Outcome.Detriment - AI will draw a card all the time (Homage choice)
    // TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
    TwoChoiceVote vote = new TwoChoiceVote("Carnage (sacrifice and destroy)", "Homage (draw a card)", Outcome.Detriment);
    vote.doVotes(source, game);
    int carnageCount = vote.getVoteCount(true);
    int homageCount = vote.getVoteCount(false);
    if (carnageCount > homageCount) {
        // carnage
        Permanent permanent = source.getSourcePermanentIfItStillExists(game);
        if (permanent != null && permanent.isControlledBy(source.getControllerId())) {
            permanent.sacrifice(source, game);
        }
        new DestroyAllEffect(StaticFilters.FILTER_PERMANENT_NON_LAND).apply(game, source);
    } else {
        // homage or tied
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            player.drawCards(1, source, game);
        }
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TwoChoiceVote(mage.choices.TwoChoiceVote) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Aggregations

DestroyAllEffect (mage.abilities.effects.common.DestroyAllEffect)15 Player (mage.players.Player)9 FilterPermanent (mage.filter.FilterPermanent)8 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)7 Permanent (mage.game.permanent.Permanent)7 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)5 UUID (java.util.UUID)3 FilterNonlandPermanent (mage.filter.common.FilterNonlandPermanent)3 OneShotEffect (mage.abilities.effects.OneShotEffect)2 Choice (mage.choices.Choice)2 ChoiceCreatureType (mage.choices.ChoiceCreatureType)2 TwoChoiceVote (mage.choices.TwoChoiceVote)2 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Objects (java.util.Objects)1 MageInt (mage.MageInt)1 MageObject (mage.MageObject)1