Search in sources :

Example 41 with SacrificeTargetCost

use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.

the class PillarTombsOfAkuEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player activePlayer = game.getPlayer(game.getActivePlayerId());
    if (activePlayer == null) {
        return false;
    }
    if (activePlayer.chooseUse(Outcome.Sacrifice, "Sacrifice a creature?", source, game)) {
        Cost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent());
        if (cost.canPay(source, source, activePlayer.getId(), game) && cost.pay(source, game, source, activePlayer.getId(), true)) {
            return true;
        }
    }
    activePlayer.loseLife(5, game, source, false);
    return new SacrificeSourceEffect().apply(game, source);
}
Also used : Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) SacrificeSourceEffect(mage.abilities.effects.common.SacrificeSourceEffect) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 42 with SacrificeTargetCost

use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.

the class RakdosRiteknifeEffect method makeAbility.

private static Ability makeAbility(Permanent permanent, Game game) {
    Ability ability = new SimpleActivatedAbility(new AddCountersTargetEffect(CounterType.BLOOD.createInstance()).setText("put a blood counter on " + permanent.getName()).setTargetPointer(new FixedTarget(permanent, game)), new TapSourceCost());
    ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT)));
    return ability;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) EquipAbility(mage.abilities.keyword.EquipAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) TapSourceCost(mage.abilities.costs.common.TapSourceCost) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 43 with SacrificeTargetCost

use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.

the class SacrificeCostConvertedMana method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    for (Cost cost : sourceAbility.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            SacrificeTargetCost sacrificeCost = (SacrificeTargetCost) cost;
            int totalCMC = 0;
            for (Permanent permanent : sacrificeCost.getPermanents()) {
                totalCMC += permanent.getManaValue();
            }
            return totalCMC;
        }
    }
    return 0;
}
Also used : SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) Permanent(mage.game.permanent.Permanent) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost)

Example 44 with SacrificeTargetCost

use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.

the class EbonPraetorEffect 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.THRULL, game) && sourceCreature != null) {
                sourceCreature.addCounters(CounterType.P1P0.createInstance(), source.getControllerId(), source, game);
                return true;
            }
        }
    }
    return true;
}
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 45 with SacrificeTargetCost

use of mage.abilities.costs.common.SacrificeTargetCost in project mage by magefree.

the class FirecatBlitzEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int xValue = source.getManaCostsToPay().getX();
        for (Cost cost : source.getCosts()) {
            if (cost instanceof SacrificeTargetCost) {
                xValue = ((SacrificeTargetCost) cost).getPermanents().size();
            }
        }
        CreateTokenEffect effect = new CreateTokenEffect(new ElementalCatToken(), xValue);
        effect.apply(game, source);
        for (UUID tokenId : effect.getLastAddedTokenIds()) {
            Permanent tokenPermanent = game.getPermanent(tokenId);
            if (tokenPermanent != null) {
                ExileTargetEffect exileEffect = new ExileTargetEffect(null, "", Zone.BATTLEFIELD);
                exileEffect.setTargetPointer(new FixedTarget(tokenPermanent, game));
                game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) ElementalCatToken(mage.game.permanent.token.ElementalCatToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) UUID(java.util.UUID) SacrificeXTargetCost(mage.abilities.costs.common.SacrificeXTargetCost) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Aggregations

SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)51 Cost (mage.abilities.costs.Cost)38 Player (mage.players.Player)37 Permanent (mage.game.permanent.Permanent)30 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)25 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)13 Card (mage.cards.Card)12 UUID (java.util.UUID)11 FilterCard (mage.filter.FilterCard)8 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)8 TapSourceCost (mage.abilities.costs.common.TapSourceCost)7 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)7 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)4 CardsImpl (mage.cards.CardsImpl)4 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)4 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)4 MageObject (mage.MageObject)3 Ability (mage.abilities.Ability)3 FilterControlledLandPermanent (mage.filter.common.FilterControlledLandPermanent)3 TargetPlayer (mage.target.TargetPlayer)3