Search in sources :

Example 81 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl 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 82 with ManaCostsImpl

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

the class PuppetMasterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = (Permanent) getValue("attachedTo");
    if (controller == null || permanent == null) {
        return false;
    }
    Card card = permanent.getMainCard();
    if (card == null || card.getZoneChangeCounter(game) != permanent.getZoneChangeCounter(game) + 1) {
        return false;
    }
    controller.moveCards(card, Zone.HAND, source, game);
    if (game.getState().getZone(card.getId()) != Zone.HAND) {
        return false;
    }
    card = game.getCard(source.getSourceId());
    if (card == null || card.getZoneChangeCounter(game) != source.getSourceObjectZoneChangeCounter() + 1) {
        return false;
    }
    Cost cost = new ManaCostsImpl("{U}{U}{U}");
    if (!controller.chooseUse(Outcome.Neutral, "Pay " + cost.getText() + " to return " + card.getLogName() + " to its owner's hand?", source, game) || !cost.pay(source, game, source, controller.getId(), false, null)) {
        return true;
    }
    controller.moveCards(card, Zone.HAND, source, game);
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Card(mage.cards.Card)

Example 83 with ManaCostsImpl

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

the class SedrisTheTraitorKingEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (UUID cardId : controller.getGraveyard()) {
            Card card = game.getCard(cardId);
            if (card != null && card.isCreature(game)) {
                UnearthAbility ability = new UnearthAbility(new ManaCostsImpl("{2}{B}"));
                ability.setSourceId(cardId);
                ability.setControllerId(card.getOwnerId());
                game.getState().addOtherAbility(card, ability);
            }
        }
        return true;
    }
    return false;
}
Also used : UnearthAbility(mage.abilities.keyword.UnearthAbility) Player(mage.players.Player) UUID(java.util.UUID) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Card(mage.cards.Card)

Example 84 with ManaCostsImpl

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

the class SeizuresEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment == null) {
        return false;
    }
    Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
    if (enchanted == null) {
        return false;
    }
    Player player = game.getPlayer(enchanted.getControllerId());
    if (player != null) {
        Cost cost = new ManaCostsImpl("{3}");
        if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + " to avoid damage?", source, game)) {
            cost.clearPaid();
            if (cost.pay(source, game, source, player.getId(), false, null)) {
                return true;
            }
        }
        player.damage(3, source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Example 85 with ManaCostsImpl

use of mage.abilities.costs.mana.ManaCostsImpl 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

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