use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class LiesaForgottenArchangelReplacementEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return that card to its owner's hand");
effect.setTargetPointer(targetPointer);
DelayedTriggeredAbility ability = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(ability, source);
return true;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class WithdrawEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
effect.apply(game, source);
Permanent secondCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget());
if (secondCreature != null) {
Player creatureController = game.getPlayer(secondCreature.getControllerId());
if (creatureController != null) {
Cost cost = ManaUtil.createManaCost(1, false);
if (creatureController.chooseUse(Outcome.Benefit, "Pay {1}? (Otherwise " + secondCreature.getName() + " will be returned to its owner's hand)", source, game)) {
cost.pay(source, game, source, creatureController.getId(), false);
}
if (!cost.isPaid()) {
creatureController.moveCards(secondCreature, Zone.HAND, source, game);
}
}
}
return true;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class StringOfDisappearancesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
Player affectedPlayer = game.getPlayer(permanent.getControllerId());
new ReturnToHandTargetEffect().apply(game, source);
if (affectedPlayer == null) {
return false;
}
if (!affectedPlayer.chooseUse(Outcome.Copy, "Pay {U}{U} to copy the spell?", source, game)) {
return true;
}
Cost cost = new ManaCostsImpl("{U}{U}");
if (!cost.pay(source, game, source, affectedPlayer.getId(), false, null)) {
return true;
}
Spell spell = game.getStack().getSpell(source.getSourceId());
if (spell == null) {
return true;
}
spell.createCopyOnStack(game, source, affectedPlayer.getId(), true);
return true;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class UginTheIneffableLookAtFaceDownEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = ((ZoneChangeEvent) event);
if (zEvent.getToZone() == Zone.BATTLEFIELD || tokenRefs.stream().noneMatch(tokenRef -> tokenRef.refersTo(zEvent.getTarget(), game))) {
return false;
}
this.getEffects().clear();
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(cardRef));
this.addEffect(effect);
return true;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class IlhargTheRazeBoarEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCard target = new TargetCardInHand(0, 1, StaticFilters.FILTER_CARD_CREATURE);
if (!player.choose(outcome, player.getHand(), target, game)) {
return false;
}
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return false;
}
player.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
return false;
}
game.getCombat().addAttackingCreature(permanent.getId(), game);
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return " + permanent.getName() + " to its owner's hand");
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source);
return true;
}
Aggregations