use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class InameLifeAspectEffect 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) {
if (controller.chooseUse(outcome, "Exile " + sourceObject.getLogName() + " to return Spirit cards?", source, game)) {
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(getTargetPointer());
effect.getTargetPointer().init(game, source);
new ExileSourceEffect().apply(game, source);
return effect.apply(game, source);
}
return true;
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class GreasefangOkibaBossEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getFirstTarget());
if (controller == null || card == null || game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
return false;
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect hasteEffect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
hasteEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(hasteEffect, source);
Effect bounceEffect = new ReturnToHandTargetEffect().setText("return it to your hand");
bounceEffect.setTargetPointer(new FixedTarget(permanent, game));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(bounceEffect), source);
}
return true;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class BroodOfCockroachesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedLifeLost = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseLifeSourceControllerEffect(1));
game.addDelayedTriggeredAbility(delayedLifeLost, source);
Effect effect = new ReturnToHandTargetEffect();
effect.setText("return {this} to your 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 DermoplasmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent thisCreature = game.getPermanent(source.getId());
FilterCreatureCard filter = new FilterCreatureCard("a creature card with a morph ability");
filter.add(new AbilityPredicate(MorphAbility.class));
Effect effect = new PutCardFromHandOntoBattlefieldEffect(filter);
if (effect.apply(game, source)) {
if (thisCreature != null) {
effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(thisCreature.getId(), game));
effect.apply(game, source);
return true;
}
}
return false;
}
use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class FumbleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget());
Player player = game.getPlayer(source.getControllerId());
if (player == null || permanent == null) {
return false;
}
List<Permanent> attachments = new ArrayList<>();
for (UUID permId : permanent.getAttachments()) {
Permanent attachment = game.getPermanent(permId);
if (attachment != null) {
if (attachment.hasSubtype(SubType.AURA, game) || attachment.hasSubtype(SubType.EQUIPMENT, game)) {
attachments.add(attachment);
}
}
}
new ReturnToHandTargetEffect().apply(game, source);
if (!attachments.isEmpty()) {
Target target = new TargetCreaturePermanent(1, 1, StaticFilters.FILTER_PERMANENT_CREATURE, true);
Permanent newCreature = null;
if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) {
newCreature = game.getPermanent(target.getFirstTarget());
}
for (Permanent attachment : attachments) {
if (!attachment.hasSubtype(SubType.AURA, game) && !attachment.hasSubtype(SubType.EQUIPMENT, game)) {
continue;
}
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, player.getId());
effect.setTargetPointer(new FixedTarget(attachment, game));
game.addEffect(effect, source);
if (newCreature != null) {
attachment.attachTo(newCreature.getId(), source, game);
}
}
}
return true;
}
Aggregations