Search in sources :

Example 1 with ExileFromGraveCost

use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.

the class DemilichPlayEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (source.getSourceId().equals(objectId) && source.isControlledBy(affectedControllerId) && game.getState().getZone(objectId) == Zone.GRAVEYARD) {
        Player controller = game.getPlayer(affectedControllerId);
        if (controller != null) {
            Costs<Cost> costs = new CostsImpl<>();
            costs.add(new ExileFromGraveCost(new TargetCardInYourGraveyard(4, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY_FROM_YOUR_GRAVEYARD)));
            controller.setCastSourceIdWithAlternateMana(objectId, new ManaCostsImpl<>("{U}{U}{U}{U}"), costs);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) CostsImpl(mage.abilities.costs.CostsImpl) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Cost(mage.abilities.costs.Cost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost)

Example 2 with ExileFromGraveCost

use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.

the class UrzasTomeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    new DrawCardSourceControllerEffect(1).apply(game, source);
    if (controller != null && controller.chooseUse(Outcome.Exile, "Exile a historic card from your graveyard?", source, game)) {
        Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard(new FilterHistoricCard()));
        if (cost.canPay(source, source, controller.getId(), game)) {
            if (cost.pay(source, game, source, controller.getId(), false, null)) {
                return true;
            }
        }
    }
    if (controller != null) {
        controller.discard(1, false, false, source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) DrawCardSourceControllerEffect(mage.abilities.effects.common.DrawCardSourceControllerEffect) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) FilterHistoricCard(mage.filter.common.FilterHistoricCard) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost)

Example 3 with ExileFromGraveCost

use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.

the class DelveEffect method addSpecialAction.

@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !controller.getGraveyard().isEmpty()) {
        if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) {
            SpecialAction specialAction = new DelveSpecialAction(this);
            specialAction.setControllerId(source.getControllerId());
            specialAction.setSourceId(source.getSourceId());
            int unpaidAmount = unpaid.getMana().getGeneric();
            if (!controller.getManaPool().isAutoPayment() && unpaidAmount > 1) {
                unpaidAmount = 1;
            }
            specialAction.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard(0, Math.min(controller.getGraveyard().size(), unpaidAmount), new FilterCard("cards from your graveyard"), true)));
            if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
                game.getState().getSpecialActions().add(specialAction);
            }
        }
    }
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) SpecialAction(mage.abilities.SpecialAction) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) ValueHint(mage.abilities.hint.ValueHint)

Example 4 with ExileFromGraveCost

use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.

the class DelveEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Spell spell = game.getStack().getSpell(source.getSourceId());
    if (controller != null && spell != null) {
        ExileFromGraveCost exileFromGraveCost = (ExileFromGraveCost) source.getCosts().get(0);
        List<Card> exiledCards = exileFromGraveCost.getExiledCards();
        if (!exiledCards.isEmpty()) {
            Cards toDelve = new CardsImpl();
            for (Card card : exiledCards) {
                toDelve.add(card);
            }
            ManaPool manaPool = controller.getManaPool();
            manaPool.addMana(Mana.ColorlessMana(toDelve.size()), game, source);
            manaPool.unlockManaType(ManaType.COLORLESS);
            String keyString = CardUtil.getCardZoneString("delvedCards", source.getSourceId(), game);
            @SuppressWarnings("unchecked") Cards delvedCards = (Cards) game.getState().getValue(keyString);
            if (delvedCards == null) {
                game.getState().setValue(keyString, toDelve);
            } else {
                delvedCards.addAll(toDelve);
            }
            // can't use mana abilities after that (delve cost must be payed after mana abilities only)
            spell.setCurrentActivatingManaAbilitiesStep(ActivationManaAbilityStep.AFTER);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) ManaPool(mage.players.ManaPool) Spell(mage.game.stack.Spell) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 5 with ExileFromGraveCost

use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.

the class CorpseweftEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int amount = 0;
        for (Cost cost : source.getCosts()) {
            if (cost instanceof ExileFromGraveCost) {
                amount = ((ExileFromGraveCost) cost).getExiledCards().size() * 2;
                new CreateTokenEffect(new CorpseweftZombieToken(amount, amount), 1, true, false).apply(game, source);
            }
        }
        if (amount > 0) {
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) Cost(mage.abilities.costs.Cost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) CorpseweftZombieToken(mage.game.permanent.token.CorpseweftZombieToken)

Aggregations

ExileFromGraveCost (mage.abilities.costs.common.ExileFromGraveCost)9 Player (mage.players.Player)9 Cost (mage.abilities.costs.Cost)7 FilterCard (mage.filter.FilterCard)4 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)4 TapSourceCost (mage.abilities.costs.common.TapSourceCost)3 MageObject (mage.MageObject)2 Card (mage.cards.Card)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 SpecialAction (mage.abilities.SpecialAction)1 CostsImpl (mage.abilities.costs.CostsImpl)1 VariableCost (mage.abilities.costs.VariableCost)1 ExileXFromYourGraveCost (mage.abilities.costs.common.ExileXFromYourGraveCost)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 VariableManaCost (mage.abilities.costs.mana.VariableManaCost)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)1 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)1