Search in sources :

Example 1 with DiscardTargetEffect

use of mage.abilities.effects.common.discard.DiscardTargetEffect in project mage by magefree.

the class PullingTeethEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int cardsToDiscard;
        if (ClashEffect.getInstance().apply(game, source)) {
            cardsToDiscard = 2;
        } else {
            cardsToDiscard = 1;
        }
        DiscardTargetEffect effect = new DiscardTargetEffect(cardsToDiscard);
        effect.apply(game, source);
        return true;
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect)

Example 2 with DiscardTargetEffect

use of mage.abilities.effects.common.discard.DiscardTargetEffect in project mage by magefree.

the class RakdossReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayerOrPlaneswalkerController(source.getFirstTarget());
    if (player == null) {
        return false;
    }
    Effect effect = new DiscardTargetEffect(ManacostVariableValue.REGULAR);
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 3 with DiscardTargetEffect

use of mage.abilities.effects.common.discard.DiscardTargetEffect in project mage by magefree.

the class BlightningEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayerOrPlaneswalkerController(source.getFirstTarget());
    if (player == null) {
        return false;
    }
    Effect effect = new DiscardTargetEffect(2);
    effect.setTargetPointer(new FixedTarget(player.getId(), game));
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect)

Example 4 with DiscardTargetEffect

use of mage.abilities.effects.common.discard.DiscardTargetEffect in project mage by magefree.

the class PlaguecrafterEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    List<UUID> perms = new ArrayList<>();
    List<UUID> cantSac = new ArrayList<>();
    for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player == null) {
            continue;
        }
        FilterControlledPermanent filter = new FilterControlledPermanent("creature or planeswalker");
        filter.add(Predicates.or(CardType.CREATURE.getPredicate(), CardType.PLANESWALKER.getPredicate()));
        TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true);
        if (target.canChoose(source.getSourceId(), player.getId(), game)) {
            while (!target.isChosen() && player.canRespond()) {
                player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
            }
            perms.addAll(target.getTargets());
        } else {
            cantSac.add(playerId);
        }
    }
    for (UUID permID : perms) {
        Permanent permanent = game.getPermanent(permID);
        if (permanent != null) {
            permanent.sacrifice(source, game);
        }
    }
    for (UUID playerId : cantSac) {
        Effect discardEffect = new DiscardTargetEffect(1);
        discardEffect.setTargetPointer(new FixedTarget(playerId, game));
        discardEffect.apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) ArrayList(java.util.ArrayList) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent)

Example 5 with DiscardTargetEffect

use of mage.abilities.effects.common.discard.DiscardTargetEffect in project mage by magefree.

the class ChainOfSmogEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        UUID targetId = source.getFirstTarget();
        Player affectedPlayer = game.getPlayer(targetId);
        if (affectedPlayer != null) {
            Effect effect = new DiscardTargetEffect(2);
            effect.setTargetPointer(new FixedTarget(targetId, game));
            effect.apply(game, source);
            if (affectedPlayer.chooseUse(Outcome.Copy, "Copy the spell?", source, game)) {
                Spell spell = game.getStack().getSpell(source.getSourceId());
                if (spell != null) {
                    spell.createCopyOnStack(game, source, affectedPlayer.getId(), true);
                    game.informPlayers(affectedPlayer.getLogName() + " copies " + spell.getName() + '.');
                }
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) DiscardTargetEffect(mage.abilities.effects.common.discard.DiscardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Aggregations

DiscardTargetEffect (mage.abilities.effects.common.discard.DiscardTargetEffect)5 Player (mage.players.Player)5 Effect (mage.abilities.effects.Effect)4 OneShotEffect (mage.abilities.effects.OneShotEffect)4 FixedTarget (mage.target.targetpointer.FixedTarget)4 UUID (java.util.UUID)2 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)2 TargetPlayer (mage.target.TargetPlayer)2 ArrayList (java.util.ArrayList)1 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)1 Permanent (mage.game.permanent.Permanent)1 Spell (mage.game.stack.Spell)1 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)1