Search in sources :

Example 81 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class FalkenrathTorturerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0);
            Permanent sourceCreature = game.getPermanent(source.getSourceId());
            if (sacrificedCreature.hasSubtype(SubType.HUMAN, game) && sourceCreature != null) {
                sourceCreature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
                return true;
            }
        }
    }
    return false;
}
Also used : SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost)

Example 82 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class EyeOfYawgmothEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    int power = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost && !((SacrificeTargetCost) cost).getPermanents().isEmpty()) {
            power = ((SacrificeTargetCost) cost).getPermanents().get(0).getPower().getValue();
            break;
        }
    }
    if (power > 0) {
        Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, power));
        controller.revealCards(source, cards, game);
        TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
        if (controller.choose(Outcome.DrawCard, cards, target, game)) {
            Card card = cards.get(target.getFirstTarget(), game);
            if (card != null) {
                controller.moveCards(card, Zone.HAND, source, game);
                cards.remove(card);
            }
        }
        controller.moveCards(cards, Zone.EXILED, source, game);
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetCard(mage.target.TargetCard) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

Example 83 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class FlashOfInsightEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (controller == null || sourceObject == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    for (Cost cost : source.getCosts()) {
        if (cost instanceof ExileFromGraveCost) {
            xValue = ((ExileFromGraveCost) cost).getExiledCards().size();
        }
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
    controller.lookAtCards(sourceObject.getIdName(), cards, game);
    TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
    target.setNotTarget(true);
    if (controller.chooseTarget(Outcome.DrawCard, cards, target, source, game)) {
        Card card = cards.get(target.getFirstTarget(), game);
        if (card != null) {
            controller.moveCards(card, Zone.HAND, source, game);
            cards.remove(card);
        }
    }
    controller.putCardsOnBottomOfLibrary(cards, game, source, true);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) MageObject(mage.MageObject) TargetCard(mage.target.TargetCard) ExileXFromYourGraveCost(mage.abilities.costs.common.ExileXFromYourGraveCost) Cost(mage.abilities.costs.Cost) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) FilterCard(mage.filter.FilterCard) TargetCard(mage.target.TargetCard)

Example 84 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class GlacianPowerstoneEngineerCost method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int xValue = source.getManaCostsToPay().getX();
    for (Cost cost : source.getCosts()) {
        if (cost instanceof GlacianPowerstoneEngineerCost) {
            xValue = ((GlacianPowerstoneEngineerCost) cost).getAmount();
            break;
        }
    }
    if (xValue < 1) {
        return false;
    }
    Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
    if (cards.isEmpty()) {
        return false;
    }
    TargetCard targetCard = new TargetCardInLibrary(1, StaticFilters.FILTER_CARD);
    player.choose(outcome, cards, targetCard, game);
    Card card = game.getCard(targetCard.getFirstTarget());
    if (card != null && player.moveCards(card, Zone.HAND, source, game)) {
        cards.remove(card);
    }
    player.moveCards(cards, Zone.GRAVEYARD, source, game);
    return true;
}
Also used : Player(mage.players.Player) TargetCard(mage.target.TargetCard) TapTargetCost(mage.abilities.costs.common.TapTargetCost) Cost(mage.abilities.costs.Cost) TapSourceCost(mage.abilities.costs.common.TapSourceCost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) TargetCard(mage.target.TargetCard)

Example 85 with Cost

use of mage.abilities.costs.Cost in project mage by magefree.

the class GorexTheTombshellReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    SpellAbility spellAbility = (SpellAbility) abilityToModify;
    for (Cost cost : spellAbility.getCosts()) {
        if (!(cost instanceof ExileXFromYourGraveCost)) {
            continue;
        }
        if (game.inCheckPlayableState()) {
            // allows to cast in getPlayable
            int reduction = ((ExileXFromYourGraveCost) cost).getMaxValue(spellAbility, game);
            CardUtil.adjustCost(spellAbility, reduction * 2);
        } else {
            // real cast
            int reduction = ((ExileXFromYourGraveCost) cost).getAmount();
            CardUtil.adjustCost(spellAbility, reduction * 2);
        }
        break;
    }
    return true;
}
Also used : ExileXFromYourGraveCost(mage.abilities.costs.common.ExileXFromYourGraveCost) SpellAbility(mage.abilities.SpellAbility) ExileXFromYourGraveCost(mage.abilities.costs.common.ExileXFromYourGraveCost) Cost(mage.abilities.costs.Cost)

Aggregations

Cost (mage.abilities.costs.Cost)174 Player (mage.players.Player)142 Permanent (mage.game.permanent.Permanent)86 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)41 Card (mage.cards.Card)32 UUID (java.util.UUID)30 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)29 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)26 TapSourceCost (mage.abilities.costs.common.TapSourceCost)23 FilterCard (mage.filter.FilterCard)22 MageObject (mage.MageObject)19 PayLifeCost (mage.abilities.costs.common.PayLifeCost)17 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)16 FixedTarget (mage.target.targetpointer.FixedTarget)16 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)14 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)14 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)13 ContinuousEffect (mage.abilities.effects.ContinuousEffect)12 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)11 OneShotEffect (mage.abilities.effects.OneShotEffect)9