Search in sources :

Example 91 with ManaCostsImpl

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

the class DemonicEmbracePlayEffect method applies.

@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
    if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) {
        if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
            Player player = game.getPlayer(affectedControllerId);
            if (player != null) {
                Costs<Cost> costs = new CostsImpl<>();
                costs.add(new PayLifeCost(3));
                costs.add(new DiscardCardCost());
                player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{1}{B}{B}"), costs);
                return true;
            }
        }
    }
    return false;
}
Also used : DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Player(mage.players.Player) CostsImpl(mage.abilities.costs.CostsImpl) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) PayLifeCost(mage.abilities.costs.common.PayLifeCost) PayLifeCost(mage.abilities.costs.common.PayLifeCost) DiscardCardCost(mage.abilities.costs.common.DiscardCardCost) Cost(mage.abilities.costs.Cost)

Example 92 with ManaCostsImpl

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

the class DelayingShieldUpkeepEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        int numCounters = permanent.getCounters(game).getCount(CounterType.DELAY);
        permanent.removeCounters(CounterType.DELAY.createInstance(numCounters), source, game);
        for (int i = numCounters; i > 0; i--) {
            if (controller.chooseUse(Outcome.Benefit, "Pay {1}{W}? (" + i + " counters left to pay)", source, game)) {
                Cost cost = new ManaCostsImpl<>("{1}{W}");
                if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                    continue;
                }
            }
            new LoseLifeSourceControllerEffect(1).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 93 with ManaCostsImpl

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

the class ChandrasRegulatorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaCostsImpl cost = new ManaCostsImpl("{1}");
    if (player == null) {
        return false;
    }
    if (!cost.canPay(source, source, player.getId(), game) || !player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + "? If you do, copy that ability. You may choose new targets for the copy.", source, game)) {
        return true;
    }
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return true;
    }
    StackAbility ability = (StackAbility) getValue("stackAbility");
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (ability == null || controller == null || sourcePermanent == null) {
        return false;
    }
    ability.createCopyOnStack(game, source, source.getControllerId(), true);
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) StackAbility(mage.game.stack.StackAbility)

Example 94 with ManaCostsImpl

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

the class CowedByWisdomayCostToAttackBlockEffect method getManaCostToPay.

@Override
public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !controller.getHand().isEmpty()) {
        ManaCosts manaCosts = new ManaCostsImpl();
        manaCosts.add(new GenericManaCost(controller.getHand().size()));
        return manaCosts;
    }
    return null;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 95 with ManaCostsImpl

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

the class CycloneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    int total = permanent.getCounters(game).getCount(CounterType.WIND);
    StringBuilder greens = new StringBuilder(total);
    for (int i = 0; i < total; i++) {
        greens.append("{G}");
    }
    if (this.choice(game, source, player, new ManaCostsImpl(greens.toString()))) {
        DamageEverythingEffect dmg = new DamageEverythingEffect(total);
        dmg.apply(game, source);
    } else {
        permanent.sacrifice(source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DamageEverythingEffect(mage.abilities.effects.common.DamageEverythingEffect) 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