Search in sources :

Example 61 with ManaCostsImpl

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

the class VigilForTheLostEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ManaCostsImpl cost = new ManaCostsImpl("{X}");
    cost.clearPaid();
    if (cost.payOrRollback(source, game, source, source.getControllerId())) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            player.gainLife(cost.getX(), game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 62 with ManaCostsImpl

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

the class CustomTestCard method addCustomEffect_TargetDamage.

/**
 * Add target damage ability that can be called by text: "target damage xxx"
 *
 * @param controller
 * @param damageAmount
 */
protected void addCustomEffect_TargetDamage(TestPlayer controller, int damageAmount) {
    Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(damageAmount).setText("target damage " + damageAmount), new ManaCostsImpl(""));
    ability.addTarget(new TargetAnyTarget());
    addCustomCardWithAbility("target damage " + damageAmount + " 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) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 63 with ManaCostsImpl

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

the class ElectropotenceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID creatureId = (UUID) getValue("damageSource");
    Permanent creature = game.getPermanentOrLKIBattlefield(creatureId);
    Player controller = game.getPlayer(source.getControllerId());
    if (creature != null && controller != null) {
        if (controller.chooseUse(Outcome.Damage, "Pay {2}{R} to do the damage?", source, game)) {
            // if (controller.chooseUse(Outcome.Damage, "Pay {2}{R}? If you do, " + creature.getName() + " deals damage equal to its power to any target.", game)) {
            ManaCosts manaCosts = new ManaCostsImpl("{2}{R}");
            if (manaCosts.pay(source, game, source, controller.getId(), false, null)) {
                int amount = creature.getPower().getValue();
                UUID target = source.getTargets().getFirstTarget();
                Permanent targetCreature = game.getPermanent(target);
                if (targetCreature != null) {
                    targetCreature.damage(amount, creature.getId(), source, game, false, true);
                } else {
                    Player player = game.getPlayer(target);
                    if (player != null) {
                        player.damage(amount, creature.getId(), source, game);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 64 with ManaCostsImpl

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

the class ForgottenLoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player you = game.getPlayer(source.getControllerId());
    Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (you != null && opponent != null) {
        FilterCard filter = new FilterCard();
        filter.add(new OwnerIdPredicate(you.getId()));
        Cost cost = new ManaCostsImpl("{G}");
        TargetCardInGraveyard chosenCard;
        Card card = null;
        boolean done = false;
        do {
            chosenCard = new TargetCardInGraveyard(filter);
            chosenCard.setNotTarget(true);
            if (chosenCard.canChoose(source.getSourceId(), opponent.getId(), game)) {
                opponent.chooseTarget(Outcome.ReturnToHand, chosenCard, source, game);
                card = game.getCard(chosenCard.getFirstTarget());
                if (card != null) {
                    filter.add(Predicates.not(new CardIdPredicate(card.getId())));
                    game.informPlayers("Forgotten Lore: " + opponent.getLogName() + " has chosen " + card.getLogName());
                }
            } else {
                done = true;
            }
            if (!done) {
                if (cost.canPay(source, source, you.getId(), game) && you.chooseUse(Outcome.Benefit, "Pay {G} to choose a different card ?", source, game)) {
                    cost.clearPaid();
                    if (!cost.pay(source, game, source, you.getId(), false, null)) {
                        done = true;
                    }
                } else {
                    done = true;
                }
            }
        } while (!done);
        if (card != null) {
            Cards cardsToHand = new CardsImpl();
            cardsToHand.add(card);
            you.moveCards(cardsToHand, Zone.HAND, source, game);
        }
        return true;
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) OwnerIdPredicate(mage.filter.predicate.card.OwnerIdPredicate) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) FilterCard(mage.filter.FilterCard) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Example 65 with ManaCostsImpl

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

the class JeskaiInfiltratorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Set<Card> cardsToManifest = new HashSet<>();
        cardsToManifest.add(source.getSourcePermanentIfItStillExists(game));
        cardsToManifest.add(controller.getLibrary().getFromTop(game));
        UUID exileId = UUID.randomUUID();
        controller.moveCardsToExile(cardsToManifest, source, game, false, exileId, "");
        ExileZone exileZone = game.getExile().getExileZone(exileId);
        for (Card card : exileZone.getCards(game)) {
            card.setFaceDown(true, game);
        }
        // removes Jeskai Infiltrator from Battlefield, so Jeskai Infiltrator returns as a fresh permanent to the battlefield with new position
        game.fireUpdatePlayersEvent();
        Ability newSource = source.copy();
        newSource.setWorksFaceDown(true);
        // the Set will mimic the Shuffling
        exileZone.getCards(game).forEach(card -> {
            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);
        });
        controller.moveCards(exileZone.getCards(game), Zone.BATTLEFIELD, source, game, false, true, false, null);
        return true;
    }
    return false;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DealsCombatDamageToAPlayerTriggeredAbility(mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility) Ability(mage.abilities.Ability) ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card) HashSet(java.util.HashSet) BecomesFaceDownCreatureEffect(mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect)

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