Search in sources :

Example 6 with SacrificeEffect

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

the class OmenOfFireEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                int whitePermanents = game.getBattlefield().countAll(filterWhite2, playerId, game);
                if (whitePermanents > 0) {
                    Effect effect = new SacrificeEffect(filterWhite1, whitePermanents, "");
                    effect.setTargetPointer(new FixedTarget(playerId));
                    effect.apply(game, source);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) ReturnToHandFromBattlefieldAllEffect(mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect) UUID(java.util.UUID)

Example 7 with SacrificeEffect

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

the class PirsWhimEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
    if (controller != null && !choice.chooseFriendOrFoe(controller, source, game)) {
        return false;
    }
    for (Player player : choice.getFriends()) {
        if (player != null) {
            TargetCardInLibrary target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_LAND);
            if (player.searchLibrary(target, source, game)) {
                player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null);
                player.shuffleLibrary(source, game);
            }
        }
    }
    for (Player player : choice.getFoes()) {
        if (player != null) {
            Effect effect = new SacrificeEffect(StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT, 1, "");
            effect.setTargetPointer(new FixedTarget(player.getId(), game));
            effect.apply(game, source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ChooseFriendsAndFoes(mage.choices.ChooseFriendsAndFoes) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 8 with SacrificeEffect

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

the class PhyrexianTotemTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getTargetId().equals(getSourceId())) {
        getEffects().get(0).setTargetPointer(new FixedTarget(getControllerId()));
        ((SacrificeEffect) getEffects().get(0)).setAmount(StaticValue.get(event.getAmount()));
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect)

Example 9 with SacrificeEffect

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

the class SkullStormEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    game.getOpponents(source.getControllerId()).forEach((playerId) -> {
        Player player = game.getPlayer(playerId);
        if (player != null) {
            FilterPermanent filter = new FilterCreaturePermanent();
            filter.add(new ControllerIdPredicate(playerId));
            if (game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game).isEmpty()) {
                int lifeToLose = (int) Math.ceil(player.getLife() / 2f);
                player.loseLife(lifeToLose, game, source, false);
            } else {
                Effect effect = new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, null);
                effect.setTargetPointer(new FixedTarget(playerId, game));
                effect.apply(game, source);
            }
        }
    });
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) SacrificeEffect(mage.abilities.effects.common.SacrificeEffect) Effect(mage.abilities.effects.Effect)

Example 10 with SacrificeEffect

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

the class PhyrexianObliteratorTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getTargetId().equals(this.sourceId)) {
        UUID controller = game.getControllerId(event.getSourceId());
        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)

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