use of mage.target.TargetPermanent in project mage by magefree.
the class ProteanThaumaturgeCopyApplier method createAbility.
static Ability createAbility() {
Ability ability = new ConstellationAbility(new CopyPermanentEffect(StaticFilters.FILTER_PERMANENT_CREATURE, new ProteanThaumaturgeCopyApplier(), true).setText("{this} become a copy of another target creature, except it has this ability"), true, false);
ability.addTarget(new TargetPermanent(filter));
return ability;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class StormHeraldAttachableToPredicate method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterCard filter = new FilterCard("aura cards to attach to creatures you control");
filter.add(SubType.AURA.getPredicate());
filter.add(new StormHeraldAttachablePredicate(controller.getId()));
Set<Card> possibleTargets = controller.getGraveyard().getCards(filter, source.getSourceId(), controller.getId(), game);
if (!possibleTargets.isEmpty()) {
TargetCard targetAuras = new TargetCard(0, Integer.MAX_VALUE, Zone.GRAVEYARD, filter);
targetAuras.setNotTarget(true);
controller.chooseTarget(outcome, new CardsImpl(possibleTargets), targetAuras, source, game);
// Move the cards to the battlefield to a creature you control
List<Permanent> toExile = new ArrayList<>();
for (UUID auraId : targetAuras.getTargets()) {
Card auraCard = game.getCard(auraId);
if (auraCard != null) {
FilterPermanent filterAttachTo = new FilterControlledCreaturePermanent("creature you control to attach " + auraCard.getIdName() + " to");
filterAttachTo.add(new StormHeraldAttachableToPredicate(auraCard));
TargetPermanent targetCreature = new TargetPermanent(filterAttachTo);
targetCreature.setNotTarget(true);
if (controller.choose(Outcome.PutCardInPlay, targetCreature, source.getSourceId(), game)) {
Permanent targetPermanent = game.getPermanent(targetCreature.getFirstTarget());
if (!targetPermanent.cantBeAttachedBy(auraCard, source, game, true)) {
game.getState().setValue("attachTo:" + auraCard.getId(), targetPermanent);
controller.moveCards(auraCard, Zone.BATTLEFIELD, source, game);
targetPermanent.addAttachment(auraCard.getId(), source, game);
Permanent permanent = game.getPermanent(auraId);
if (permanent != null) {
toExile.add(permanent);
}
}
}
}
}
ContinuousEffect continuousEffect = new StormHeraldReplacementEffect();
continuousEffect.setTargetPointer(new FixedTargets(toExile, game));
game.addEffect(continuousEffect, source);
Effect exileEffect = new ExileTargetEffect("exile those Auras");
exileEffect.setTargetPointer(new FixedTargets(toExile, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source);
}
return true;
}
return false;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class TazeemRaptorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetPermanent target = new TargetControlledPermanent(0, 1, StaticFilters.FILTER_CONTROLLED_PERMANENT_LAND, true);
player.choose(outcome, target, source.getSourceId(), game);
return player.moveCards(game.getCard(target.getFirstTarget()), Zone.HAND, source, game);
}
use of mage.target.TargetPermanent in project mage by magefree.
the class TormentOfVenomEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
new AddCountersTargetEffect(CounterType.M1M1.createInstance(3)).apply(game, source);
Player controllingPlayer = game.getPlayer(targetCreature.getControllerId());
if (controllingPlayer != null) {
int permanents = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_NON_LAND, controllingPlayer.getId(), game);
if (permanents > 0 && controllingPlayer.chooseUse(outcome, "Sacrifices a nonland permanent?", "Otherwise you have to discard a card or lose 3 life.", "Sacrifice", "Discard or life loss", source, game)) {
FilterPermanent filter = new FilterControlledPermanent("another nonland permanent");
filter.add(Predicates.not(CardType.LAND.getPredicate()));
filter.add(Predicates.not(new PermanentIdPredicate(targetCreature.getId())));
Target target = new TargetPermanent(filter);
if (controllingPlayer.choose(outcome, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source, game);
return true;
}
}
}
if (!controllingPlayer.getHand().isEmpty() && controllingPlayer.chooseUse(outcome, "Discard a card?", "Otherwise you lose 3 life.", "Discard", "Lose 3 life", source, game)) {
controllingPlayer.discardOne(false, false, source, game);
return true;
}
controllingPlayer.loseLife(3, game, source, false);
return true;
}
}
return false;
}
use of mage.target.TargetPermanent in project mage by magefree.
the class TovolarDireOverlordEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
game.setDaytime(false);
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return true;
}
TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
player.choose(outcome, target, source.getControllerId(), game);
for (UUID permanentId : target.getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.transform(source, game);
}
}
return true;
}
Aggregations