Search in sources :

Example 1 with SacrificeControllerEffect

use of mage.abilities.effects.common.SacrificeControllerEffect in project mage by magefree.

the class DralnuLichLordFlashbackEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    DamageEvent damageEvent = (DamageEvent) event;
    new SacrificeControllerEffect(new FilterPermanent(), damageEvent.getAmount(), "").apply(game, source);
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect) DamageEvent(mage.game.events.DamageEvent)

Example 2 with SacrificeControllerEffect

use of mage.abilities.effects.common.SacrificeControllerEffect in project mage by magefree.

the class CrovaxTheCursedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent sourceObject = (Permanent) source.getSourceObjectIfItStillExists(game);
        int creatures = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURES, source.getControllerId(), game);
        if (creatures > 0 && controller.chooseUse(outcome, "Sacrifice a creature?", source, game)) {
            if (new SacrificeControllerEffect(StaticFilters.FILTER_PERMANENT_CREATURES, 1, "").apply(game, source)) {
                if (sourceObject != null) {
                    sourceObject.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
                    game.informPlayers(controller.getLogName() + " puts a +1/+1 counter on " + sourceObject.getName());
                }
            }
        } else if (sourceObject != null && sourceObject.getCounters(game).containsKey(CounterType.P1P1)) {
            sourceObject.removeCounters(CounterType.P1P1.getName(), 1, source, game);
            game.informPlayers(controller.getLogName() + " removes a +1/+1 counter from " + sourceObject.getName());
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect)

Example 3 with SacrificeControllerEffect

use of mage.abilities.effects.common.SacrificeControllerEffect in project mage by magefree.

the class InfernalDenizenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getSourceId());
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        DynamicValue swamps = new PermanentsOnBattlefieldCount(filter);
        boolean canSac = swamps.calculate(game, source, this) > 1;
        Effect effect = new SacrificeControllerEffect(filter, 2, "Sacrifice two Swamps");
        effect.apply(game, source);
        if (!canSac) {
            if (creature != null) {
                creature.tap(source, game);
            }
            TargetOpponent targetOpp = new TargetOpponent(true);
            if (targetOpp.canChoose(source.getSourceId(), player.getId(), game) && targetOpp.choose(Outcome.Detriment, player.getId(), source.getSourceId(), game)) {
                Player opponent = game.getPlayer(targetOpp.getFirstTarget());
                if (opponent != null) {
                    FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creature controlled by " + player.getLogName());
                    filter2.add(new ControllerIdPredicate(player.getId()));
                    TargetCreaturePermanent targetCreature = new TargetCreaturePermanent(1, 1, filter2, true);
                    targetCreature.setTargetController(opponent.getId());
                    if (targetCreature.canChoose(source.getSourceId(), id, game) && opponent.chooseUse(Outcome.GainControl, "Gain control of a creature?", source, game) && opponent.chooseTarget(Outcome.GainControl, targetCreature, source, game)) {
                        ConditionalContinuousEffect giveEffect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom, true, opponent.getId()), SourceOnBattlefieldCondition.instance, "");
                        giveEffect.setTargetPointer(new FixedTarget(targetCreature.getFirstTarget(), game));
                        game.addEffect(giveEffect, source);
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DynamicValue(mage.abilities.dynamicvalue.DynamicValue)

Example 4 with SacrificeControllerEffect

use of mage.abilities.effects.common.SacrificeControllerEffect in project mage by magefree.

the class YawgmothDemonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int artifacts = game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game);
        boolean artifactSacrificed = false;
        if (artifacts > 0 && controller.chooseUse(outcome, "Sacrifice an artifact?", source, game)) {
            if (new SacrificeControllerEffect(new FilterArtifactPermanent(), 1, "").apply(game, source)) {
                artifactSacrificed = true;
            }
        }
        if (!artifactSacrificed) {
            Permanent sourceObject = (Permanent) source.getSourceObjectIfItStillExists(game);
            if (sourceObject != null) {
                sourceObject.tap(source, game);
                controller.damage(2, source.getSourceId(), source, game);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) Permanent(mage.game.permanent.Permanent) FilterArtifactPermanent(mage.filter.common.FilterArtifactPermanent) SacrificeControllerEffect(mage.abilities.effects.common.SacrificeControllerEffect)

Aggregations

SacrificeControllerEffect (mage.abilities.effects.common.SacrificeControllerEffect)4 Permanent (mage.game.permanent.Permanent)3 Player (mage.players.Player)3 FilterPermanent (mage.filter.FilterPermanent)2 ConditionalContinuousEffect (mage.abilities.decorator.ConditionalContinuousEffect)1 DynamicValue (mage.abilities.dynamicvalue.DynamicValue)1 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 FilterArtifactPermanent (mage.filter.common.FilterArtifactPermanent)1 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)1 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)1 DamageEvent (mage.game.events.DamageEvent)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1 TargetOpponent (mage.target.common.TargetOpponent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1