use of mage.abilities.effects.common.ReturnToHandSourceEffect in project mage by magefree.
the class RecoverEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card sourceCard = game.getCard(source.getSourceId());
if (controller != null && sourceCard != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
if (controller.chooseUse(Outcome.Damage, "Pay " + cost.getText() + " to recover " + sourceCard.getLogName() + "? (Otherwise the card will be exiled)", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, controller.getId(), false, null)) {
return new ReturnToHandSourceEffect().apply(game, source);
}
}
return new ExileSourceEffect().apply(game, source);
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandSourceEffect in project mage by magefree.
the class MetathranAerostatEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int xValue = source.getManaCostsToPay().getX();
FilterCreatureCard filter = new FilterCreatureCard("a creature with mana value " + xValue);
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, xValue));
if (new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source)) {
return new ReturnToHandSourceEffect(true).apply(game, source);
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandSourceEffect in project mage by magefree.
the class ViashinoSandswimmerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
if (controller.flipCoin(source, game, true)) {
new ReturnToHandSourceEffect().apply(game, source);
return true;
} else {
new SacrificeSourceEffect().apply(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandSourceEffect in project mage by magefree.
the class SakashimaTheImpostorCopyApplier method apply.
@Override
public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
blueprint.addSuperType(SuperType.LEGENDARY);
blueprint.setName("Sakashima the Impostor");
// {2}{U}{U}: Return Sakashima the Impostor to its owner's hand at the beginning of the next end step
blueprint.getAbilities().add(new SimpleActivatedAbility(Zone.BATTLEFIELD, new CreateDelayedTriggeredAbilityEffect(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnToHandSourceEffect(true)), false), new ManaCostsImpl("{2}{U}{U}")));
return true;
}
use of mage.abilities.effects.common.ReturnToHandSourceEffect in project mage by magefree.
the class AethermagesTouchEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
FilterCreatureCard filter = new FilterCreatureCard("a creature card to put onto the battlefield");
controller.revealCards(sourceObject.getIdName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
if (cards.count(filter, game) > 0 && controller.choose(outcome, cards, target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
cards.remove(card);
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
// It gains \"At the beginning of your end step, return this creature to its owner's hand.\"
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
Ability ability = new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new ReturnToHandSourceEffect(true), TargetController.YOU, null, false);
ContinuousEffect effect = new GainAbilityTargetEffect(ability, Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
return false;
}
Aggregations