Search in sources :

Example 46 with SacrificeTargetCost

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

the class DevouringGreedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int numberSpirits = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            numberSpirits += ((SacrificeTargetCost) cost).getPermanents().size();
        }
    }
    int amount = 2 + (numberSpirits * 2);
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    Player sourcePlayer = game.getPlayer(source.getControllerId());
    if (targetPlayer != null && sourcePlayer != null) {
        targetPlayer.loseLife(amount, game, source, false);
        sourcePlayer.gainLife(amount, game, source);
        return true;
    }
    return false;
}
Also used : SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost)

Example 47 with SacrificeTargetCost

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

the class DevouringRageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    int numberSpirits = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            numberSpirits = ((SacrificeTargetCost) cost).getPermanents().size();
        }
    }
    int amount = 3 + (numberSpirits * 3);
    Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (targetCreature != null) {
        ContinuousEffect effect = new BoostTargetEffect(amount, 0, Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost)

Example 48 with SacrificeTargetCost

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

the class AnchorToRealityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    TargetCardInLibrary target = new TargetCardInLibrary(filter);
    controller.searchLibrary(target, source, game);
    Card card = game.getCard(target.getFirstTarget());
    if (card == null) {
        controller.shuffleLibrary(source, game);
        return true;
    }
    int searchedManaValue = card.getManaValue();
    controller.moveCards(card, Zone.BATTLEFIELD, source, game);
    controller.shuffleLibrary(source, game);
    int sacrificedManaValue = 0;
    for (Cost cost : source.getCosts()) {
        if (cost instanceof SacrificeTargetCost) {
            List<Permanent> sacrificedPermanents = ((SacrificeTargetCost) cost).getPermanents();
            if (sacrificedPermanents.size() > 0) {
                sacrificedManaValue = sacrificedPermanents.get(0).getManaValue();
                break;
            }
        }
    }
    if (searchedManaValue < sacrificedManaValue) {
        controller.scry(2, source, game);
    }
    return true;
}
Also used : Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 49 with SacrificeTargetCost

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

the class BrainGorgersCounterSourceEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject sourceObject = source.getSourceObject(game);
    if (sourceObject != null) {
        SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT));
        for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) {
            cost.clearPaid();
            Player player = game.getPlayer(playerId);
            if (player != null && cost.canPay(source, source, player.getId(), game) && player.chooseUse(outcome, "Sacrifice a creature to counter " + sourceObject.getIdName() + '?', source, game)) {
                if (cost.pay(source, game, source, player.getId(), false, null)) {
                    game.informPlayers(player.getLogName() + " sacrifices a creature to counter " + sourceObject.getIdName() + '.');
                    Spell spell = game.getStack().getSpell(source.getSourceId());
                    if (spell != null) {
                        game.getStack().counter(spell.getId(), source, game);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) Player(mage.players.Player) MageObject(mage.MageObject) UUID(java.util.UUID) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) Spell(mage.game.stack.Spell)

Example 50 with SacrificeTargetCost

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

the class ArgothianWurmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        boolean costPaid = false;
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Cost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent()));
            Player player = game.getPlayer(playerId);
            if (player != null && cost.canPay(source, source, playerId, game) && player.chooseUse(Outcome.Sacrifice, "Sacrifice a land?", source, game) && cost.pay(source, game, source, playerId, true, null)) {
                costPaid = true;
            }
        }
        if (costPaid) {
            super.apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) UUID(java.util.UUID) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent)

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