Search in sources :

Example 1 with SacrificeEffect

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

the class DinOfTheFireherdEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean applied;
    Token token = new DinOfTheFireherdToken();
    applied = token.putOntoBattlefield(1, game, source, source.getControllerId());
    int blackCreaturesControllerControls = game.getBattlefield().countAll(blackCreatureFilter, source.getControllerId(), game);
    int redCreaturesControllerControls = game.getBattlefield().countAll(redCreatureFilter, source.getControllerId(), game);
    Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (targetOpponent != null) {
        Effect effect = new SacrificeEffect(new FilterControlledCreaturePermanent(), blackCreaturesControllerControls, "Target Opponent");
        effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect.apply(game, source);
        Effect effect2 = new SacrificeEffect(new FilterControlledLandPermanent(), redCreaturesControllerControls, "Target Opponent");
        effect2.setTargetPointer(new FixedTarget(targetOpponent.getId()));
        effect2.apply(game, source);
        applied = true;
    }
    return applied;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) DinOfTheFireherdToken(mage.game.permanent.token.DinOfTheFireherdToken) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) DinOfTheFireherdToken(mage.game.permanent.token.DinOfTheFireherdToken) Token(mage.game.permanent.token.Token) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent)

Example 2 with SacrificeEffect

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

the class LabyrinthRaptorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (permanent == null) {
        return false;
    }
    Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(permanent.getId(), game));
    if (player == null) {
        return false;
    }
    FilterPermanent filterPermanent = new FilterPermanent("creature blocking " + permanent.getIdName());
    filterPermanent.add(new BlockingAttackerIdPredicate(permanent.getId()));
    Effect effect = new SacrificeEffect(filterPermanent, 1, "");
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) BlockingAttackerIdPredicate(mage.filter.predicate.permanent.BlockingAttackerIdPredicate) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Example 3 with SacrificeEffect

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

the class PhyrexianNegatorTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getTargetId().equals(this.sourceId)) {
        UUID controller = game.getControllerId(event.getTargetId());
        if (controller != null) {
            Player player = game.getPlayer(controller);
            if (player != null) {
                getEffects().get(0).setTargetPointer(new FixedTarget(player.getId()));
                ((SacrificeEffect) getEffects().get(0)).setAmount(StaticValue.get(event.getAmount()));
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) UUID(java.util.UUID)

Example 4 with SacrificeEffect

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

the class ConsumeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player player = game.getPlayer(source.getFirstTarget());
    if (player == null || controller == null) {
        return false;
    }
    int greatestPower = 0;
    for (Permanent permanent : game.getBattlefield().getAllActivePermanents(player.getId())) {
        if (permanent != null && permanent.isCreature(game)) {
            greatestPower = Math.max(permanent.getPower().getValue(), greatestPower);
        }
    }
    FilterPermanent filter = new FilterCreaturePermanent("creature with power " + greatestPower);
    filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, greatestPower));
    new SacrificeEffect(filter, 1, "").apply(game, source);
    controller.gainLife(greatestPower, game, source);
    return true;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) PowerPredicate(mage.filter.predicate.mageobject.PowerPredicate) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect)

Example 5 with SacrificeEffect

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

the class EarthlinkEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = (Permanent) game.getLastKnownInformation(this.getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD);
    if (permanent != null) {
        Player controller = game.getPlayer(permanent.getControllerId());
        if (controller != null) {
            Effect effect = new SacrificeEffect(StaticFilters.FILTER_LAND, 1, "that creature's controller");
            effect.setTargetPointer(new FixedTarget(controller.getId(), game));
            effect.apply(game, source);
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) SacrificeSourceUnlessPaysEffect(mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect)

Aggregations

SacrificeEffect (mage.abilities.effects.common.SacrificeEffect)11 FixedTarget (mage.target.targetpointer.FixedTarget)10 Player (mage.players.Player)9 Effect (mage.abilities.effects.Effect)7 OneShotEffect (mage.abilities.effects.OneShotEffect)7 UUID (java.util.UUID)4 FilterPermanent (mage.filter.FilterPermanent)3 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)3 Permanent (mage.game.permanent.Permanent)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MageInt (mage.MageInt)1 Ability (mage.abilities.Ability)1 AttacksTriggeredAbility (mage.abilities.common.AttacksTriggeredAbility)1 ReturnToHandFromBattlefieldAllEffect (mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect)1 SacrificeSourceUnlessPaysEffect (mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect)1 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)1 HasteAbility (mage.abilities.keyword.HasteAbility)1 CardImpl (mage.cards.CardImpl)1 CardSetInfo (mage.cards.CardSetInfo)1