Search in sources :

Example 6 with SacrificeTargetCost

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

the class ScourgeOfSkolaValeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            int amount = ((SacrificeTargetCost) cost).getPermanents().get(0).getToughness().getValue();
            Player player = game.getPlayer(source.getControllerId());
            if (amount > 0 && player != null) {
                return new AddCountersSourceEffect(CounterType.P1P1.createInstance(amount), true).apply(game, source);
            }
        }
    }
    return false;
}
Also used : AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) Player(mage.players.Player) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TapSourceCost(mage.abilities.costs.common.TapSourceCost)

Example 7 with SacrificeTargetCost

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

the class VictimizeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT));
        if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
            // To end effects of the sacrificed creature
            game.getState().processAction(game);
            controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) CardsImpl(mage.cards.CardsImpl)

Example 8 with SacrificeTargetCost

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

the class BrutalSuppressionAdditionalCostEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
    target.setRequired(false);
    abilityToModify.addCost(new SacrificeTargetCost(target));
    return true;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost)

Example 9 with SacrificeTargetCost

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

the class OozeToken method apply.

@Override
public boolean apply(Game game, Ability source) {
    int value = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            value = ((SacrificeTargetCost) cost).getPermanents().get(0).getPower().getValue();
        }
    }
    Token token = new OozeToken(value);
    // neccessary if token has ability like DevourAbility()
    token.getAbilities().newId();
    token.putOntoBattlefield(1, game, source, source.getControllerId());
    return true;
}
Also used : SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) Token(mage.game.permanent.token.Token) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost)

Example 10 with SacrificeTargetCost

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

the class ElderSpawnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (controller != null && sourcePermanent != null) {
        TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
        SacrificeTargetCost cost = new SacrificeTargetCost(target);
        if (!controller.chooseUse(Outcome.AIDontUseIt, "Sacrifice an Island?", source, game) || !cost.canPay(source, source, source.getControllerId(), game) || !cost.pay(source, game, source, source.getControllerId(), true)) {
            sourcePermanent.sacrifice(source, game);
            controller.damage(6, sourcePermanent.getId(), source, game);
        }
        return true;
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent)

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