Search in sources :

Example 16 with ManaCosts

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

the class SquealingDevilEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaCosts cost = new ManaCostsImpl("{X}");
    if (player != null) {
        if (player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", 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.isCreature(game)) {
                    ContinuousEffect effect = new BoostTargetEffect(costX, 0, Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(permanent, game));
                    game.addEffect(effect, source);
                    return true;
                }
                return false;
            }
        }
    }
    return false;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 17 with ManaCosts

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

the class ManifestEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Ability newSource = source.copy();
        newSource.setWorksFaceDown(true);
        Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
        for (Card card : cards) {
            ManaCosts manaCosts = null;
            if (card.isCreature(game)) {
                manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
                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(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
        for (Card card : cards) {
            Permanent permanent = game.getPermanent(card.getId());
            if (permanent != null) {
                permanent.setManifested(true);
            }
        }
        return true;
    }
    return false;
}
Also used : Ability(mage.abilities.Ability) ManaCosts(mage.abilities.costs.mana.ManaCosts) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card) BecomesFaceDownCreatureEffect(mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect)

Example 18 with ManaCosts

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

the class HellkiteChargerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        ManaCosts cost = new ManaCostsImpl("{5}{R}{R}");
        if (player.chooseUse(Outcome.Damage, "Pay " + cost.getText() + '?', source, game)) {
            cost.clearPaid();
            if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                new UntapAllControllerEffect(new FilterAttackingCreature(), "").apply(game, source);
                game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
                return true;
            }
        }
    }
    return false;
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) FilterAttackingCreature(mage.filter.common.FilterAttackingCreature) Player(mage.players.Player) TurnMod(mage.game.turn.TurnMod) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) UntapAllControllerEffect(mage.abilities.effects.common.UntapAllControllerEffect)

Example 19 with ManaCosts

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

the class TariffEffect method processPlayer.

private void processPlayer(Game game, Ability source, Player player) {
    MageObject sourceObject = game.getObject(source.getSourceId());
    List<Permanent> creatures = getPermanentsWithTheHighestCMC(game, player.getId(), new FilterControlledCreaturePermanent());
    Permanent creatureToPayFor = chooseOnePermanent(game, player, creatures);
    if (creatureToPayFor != null && sourceObject != null) {
        ManaCosts manaCost = ManaCosts.removeVariableManaCost(creatureToPayFor.getManaCost());
        String message = "Pay " + manaCost.getText() + " (otherwise sacrifice " + creatureToPayFor.getName() + ")?";
        if (player.chooseUse(Outcome.Benefit, message, source, game)) {
            if (manaCost.pay(source, game, source, player.getId(), false, null)) {
                game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " has paid");
                return;
            }
        }
        game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " hasn't paid");
        creatureToPayFor.sacrifice(source, game);
    }
}
Also used : ManaCosts(mage.abilities.costs.mana.ManaCosts) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) MageObject(mage.MageObject) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent)

Example 20 with ManaCosts

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

the class ThievingAmalgamLifeLossEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player active = game.getPlayer(game.getActivePlayerId());
    if (controller == null || active == null) {
        return false;
    }
    Ability newSource = source.copy();
    newSource.setWorksFaceDown(true);
    Set<Card> cards = active.getLibrary().getTopCards(game, 1);
    cards.stream().forEach(card -> {
        ManaCosts manaCosts = null;
        if (card.isCreature(game)) {
            manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
            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, BecomesFaceDownCreatureEffect.FaceDownType.MANIFESTED), newSource);
    });
    controller.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
    cards.stream().map(Card::getId).map(game::getPermanent).filter(permanent -> permanent != null).forEach(permanent -> permanent.setManifested(true));
    return true;
}
Also used : DiesCreatureTriggeredAbility(mage.abilities.common.DiesCreatureTriggeredAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) Ability(mage.abilities.Ability) ManaCosts(mage.abilities.costs.mana.ManaCosts) DiesCreatureTriggeredAbility(mage.abilities.common.DiesCreatureTriggeredAbility) ManaCosts(mage.abilities.costs.mana.ManaCosts) Set(java.util.Set) MageObjectReference(mage.MageObjectReference) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) MageInt(mage.MageInt) FilterPermanent(mage.filter.FilterPermanent) Player(mage.players.Player) GainLifeEffect(mage.abilities.effects.common.GainLifeEffect) CardSetInfo(mage.cards.CardSetInfo) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Game(mage.game.Game) Effect(mage.abilities.effects.Effect) CardImpl(mage.cards.CardImpl) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) BecomesFaceDownCreatureEffect(mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect) Card(mage.cards.Card) mage.constants(mage.constants) Ability(mage.abilities.Ability) Player(mage.players.Player) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card) BecomesFaceDownCreatureEffect(mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect)

Aggregations

ManaCosts (mage.abilities.costs.mana.ManaCosts)21 Player (mage.players.Player)16 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)15 Permanent (mage.game.permanent.Permanent)8 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)7 MageObjectReference (mage.MageObjectReference)6 Ability (mage.abilities.Ability)6 BecomesFaceDownCreatureEffect (mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect)6 Card (mage.cards.Card)6 UUID (java.util.UUID)4 OneShotEffect (mage.abilities.effects.OneShotEffect)3 Set (java.util.Set)2 ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)2 ManaCost (mage.abilities.costs.mana.ManaCost)2 Effect (mage.abilities.effects.Effect)2 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)2 CardImpl (mage.cards.CardImpl)2 CardSetInfo (mage.cards.CardSetInfo)2 FilterPermanent (mage.filter.FilterPermanent)2 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)2