use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class NecropotenceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null && controller.moveCardsToExile(card, source, game, false, CardUtil.getCardExileZoneId(game, source), CardUtil.createObjectRealtedWindowTitle(source, game, null))) {
card.setFaceDown(true, game);
Effect returnToHandEffect = new ReturnToHandTargetEffect();
returnToHandEffect.setText("put that face down card into your hand");
returnToHandEffect.setTargetPointer(new FixedTarget(card, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU), source);
return true;
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class SwiftWarkiteEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.chooseUse(Outcome.PutCardInPlay, "Put a creature card from your hand? (No = from your graveyard)", source, game)) {
Target target = new TargetCardInHand(0, 1, filter);
controller.choose(outcome, target, source.getSourceId(), game);
Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
game.addEffect(effect, source);
Effect effect2 = new ReturnToHandTargetEffect();
effect2.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect2);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
} else {
Target target = new TargetCardInYourGraveyard(0, 1, filter);
target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game);
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent creature = game.getPermanent(card.getId());
if (creature != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
game.addEffect(effect, source);
Effect effect2 = new ReturnToHandTargetEffect();
effect2.setTargetPointer(new FixedTarget(creature.getId(), creature.getZoneChangeCounter(game)));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect2);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class SweepAwayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null && controller != null) {
if (permanent.isAttacking()) {
if (controller.chooseUse(Outcome.Neutral, "Put " + permanent.getIdName() + " on top of its owner's library (otherwise return to hand)?", source, game)) {
new PutOnLibraryTargetEffect(true).apply(game, source);
} else {
new ReturnToHandTargetEffect().apply(game, source);
}
} else {
new ReturnToHandTargetEffect().apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class TheScorpionGodEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
// Create delayed triggered ability
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return {this} to its owner's hand");
effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class BarrinsUnmakingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Condition condition = new MostCommonColorCondition(permanent.getColor(game));
if (condition.apply(game, source)) {
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(permanent, game));
return effect.apply(game, source);
}
}
return false;
}
Aggregations