Search in sources :

Example 36 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class CustomTestCard method addCustomEffect_ReturnFromAnyToHand.

/**
 * Return target card to hand that can be called by text "return from ..."
 *
 * @param controller
 */
protected void addCustomEffect_ReturnFromAnyToHand(TestPlayer controller) {
    // graveyard
    Ability ability = new SimpleActivatedAbility(new ReturnFromGraveyardToHandTargetEffect().setText("return from graveyard"), new ManaCostsImpl(""));
    ability.addTarget(new TargetCardInGraveyard(StaticFilters.FILTER_CARD));
    addCustomCardWithAbility("return from graveyard for " + controller.getName(), controller, ability);
    // exile
    ability = new SimpleActivatedAbility(new ReturnFromExileEffect(Zone.HAND).setText("return from exile"), new ManaCostsImpl(""));
    ability.addTarget(new TargetCardInExile(StaticFilters.FILTER_CARD));
    addCustomCardWithAbility("return from exile for " + controller.getName(), controller, ability);
    // library
    ability = new SimpleActivatedAbility(new SearchLibraryPutInHandEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD)).setText("return from library"), new ManaCostsImpl(""));
    addCustomCardWithAbility("return from library for " + controller.getName(), controller, ability);
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SpellAbility(mage.abilities.SpellAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) ReturnFromExileEffect(mage.abilities.effects.common.ReturnFromExileEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetCardInExile(mage.target.common.TargetCardInExile) SearchLibraryPutInHandEffect(mage.abilities.effects.common.search.SearchLibraryPutInHandEffect) ReturnFromGraveyardToHandTargetEffect(mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetCardInLibrary(mage.target.common.TargetCardInLibrary)

Example 37 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class CustomTestCard method addCustomEffect_DestroyTarget.

/**
 * Add target destroy ability that can be called by text "target destroy"
 *
 * @param controller
 */
protected void addCustomEffect_DestroyTarget(TestPlayer controller) {
    Ability ability = new SimpleActivatedAbility(new DestroyTargetEffect().setText("target destroy"), new ManaCostsImpl(""));
    ability.addTarget(new TargetPermanent());
    addCustomCardWithAbility("target destroy for " + controller.getName(), controller, ability);
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SpellAbility(mage.abilities.SpellAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetPermanent(mage.target.TargetPermanent) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 38 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class FlameblastDragonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaCosts cost = new ManaCostsImpl("{X}{R}");
    if (player != null) {
        if (player.chooseUse(Outcome.Damage, "Pay " + cost.getText() + "? If you do, Flameblast Dragon deals X damage to any target", source, game)) {
            int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
            cost.add(new GenericManaCost(costX));
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                Permanent permanent = game.getPermanent(source.getFirstTarget());
                if (permanent != null) {
                    permanent.damage(costX, source.getSourceId(), source, game, false, true);
                    return true;
                }
                Player targetPlayer = game.getPlayer(source.getFirstTarget());
                if (targetPlayer != null) {
                    targetPlayer.damage(costX, source.getSourceId(), source, game);
                    return true;
                }
                return false;
            }
        }
    }
    return false;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Permanent(mage.game.permanent.Permanent) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 39 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class GhastlyConscriptionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (controller != null && targetPlayer != null) {
        List<Card> cardsToManifest = new ArrayList<>();
        for (Card card : targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game)) {
            cardsToManifest.add(card);
            controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.GRAVEYARD, true);
        }
        if (cardsToManifest.isEmpty()) {
            return true;
        }
        Collections.shuffle(cardsToManifest);
        game.informPlayers(controller.getLogName() + " shuffles the face-down pile");
        Ability newSource = source.copy();
        newSource.setWorksFaceDown(true);
        for (Card card : cardsToManifest) {
            ManaCosts manaCosts = null;
            if (card.isCreature(game)) {
                manaCosts = card.getSpellAbility().getManaCosts();
                if (manaCosts == null) {
                    manaCosts = new ManaCostsImpl("{0}");
                }
            }
            MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
            game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
        }
        Set<Card> toBattlefield = new LinkedHashSet();
        toBattlefield.addAll(cardsToManifest);
        controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, true, false, null);
        return true;
    }
    return false;
}
Also used : Ability(mage.abilities.Ability) ManaCosts(mage.abilities.costs.mana.ManaCosts) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card) BecomesFaceDownCreatureEffect(mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect)

Example 40 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.

the class PowerLeakEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(game.getActivePlayerId());
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (player == null || permanent == null) {
        return false;
    }
    ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}");
    String message = "Pay {X} to prevent X damage from " + permanent.getLogName() + "?";
    int xValue = 0;
    if (player.chooseUse(Outcome.Neutral, message, source, game)) {
        xValue = player.announceXMana(0, Integer.MAX_VALUE, "Choose the amount of mana to pay", game, source);
        cost.add(new GenericManaCost(xValue));
        if (cost.pay(source, game, source, player.getId(), false, null)) {
            game.informPlayers(player.getLogName() + " paid {" + xValue + "} for " + permanent.getLogName());
        } else {
            game.informPlayers(player.getLogName() + " didn't pay {X} for " + permanent.getLogName());
        }
    } else {
        game.informPlayers(player.getLogName() + " didn't pay {X} for " + permanent.getLogName());
    }
    PreventDamageByTargetEffect effect = new PreventDamageByTargetEffect(Duration.OneUse, xValue, false);
    if (xValue != 0 && cost.isPaid()) {
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    player.damage(2, source.getSourceId(), source, game);
    effect.discard();
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) PreventDamageByTargetEffect(mage.abilities.effects.common.PreventDamageByTargetEffect) Player(mage.players.Player) TargetEnchantmentPermanent(mage.target.common.TargetEnchantmentPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)98 Player (mage.players.Player)63 Permanent (mage.game.permanent.Permanent)33 Ability (mage.abilities.Ability)26 Cost (mage.abilities.costs.Cost)26 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)23 UUID (java.util.UUID)16 Card (mage.cards.Card)16 ManaCosts (mage.abilities.costs.mana.ManaCosts)15 SpellAbility (mage.abilities.SpellAbility)14 FixedTarget (mage.target.targetpointer.FixedTarget)13 Test (org.junit.Test)13 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)12 ManaCost (mage.abilities.costs.mana.ManaCost)11 ContinuousEffect (mage.abilities.effects.ContinuousEffect)8 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)7 TargetPermanent (mage.target.TargetPermanent)7 MageObjectReference (mage.MageObjectReference)6 Effect (mage.abilities.effects.Effect)6 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)6