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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations