Search in sources :

Example 1 with SacrificeAllEffect

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

the class RiteOfRuinEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Set<String> choices = new HashSet<>();
    choices.add("Artifacts");
    choices.add("Creatures");
    choices.add("Lands");
    LinkedList<CardType> order = new LinkedList<>();
    ChoiceImpl choice = new ChoiceImpl(true);
    choice.setMessage("Choose a card type");
    choice.setChoices(choices);
    while (choices.size() > 1) {
        if (!controller.choose(Outcome.Sacrifice, choice, game)) {
            return false;
        }
        order.add(getCardType(choice.getChoice()));
        choices.remove(choice.getChoice());
        choice.clearChoice();
    }
    order.add(getCardType(choices.iterator().next()));
    int count = 1;
    for (CardType cardType : order) {
        FilterControlledPermanent filter = new FilterControlledPermanent(cardType + " you control");
        filter.add(cardType.getPredicate());
        new SacrificeAllEffect(count, filter).apply(game, source);
        count++;
    }
    return true;
}
Also used : Player(mage.players.Player) CardType(mage.constants.CardType) SacrificeAllEffect(mage.abilities.effects.common.SacrificeAllEffect) ChoiceImpl(mage.choices.ChoiceImpl) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent)

Example 2 with SacrificeAllEffect

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

the class ByInvitationOnlyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int number = player.getAmount(0, 13, "Choose a number between 0 and 13", game);
    return new SacrificeAllEffect(number, StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT).apply(game, source);
}
Also used : Player(mage.players.Player) SacrificeAllEffect(mage.abilities.effects.common.SacrificeAllEffect)

Aggregations

SacrificeAllEffect (mage.abilities.effects.common.SacrificeAllEffect)2 Player (mage.players.Player)2 ChoiceImpl (mage.choices.ChoiceImpl)1 CardType (mage.constants.CardType)1 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)1