use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.
the class ContemptEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent contempt = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (contempt != null) {
Permanent attachedToPermanent = game.getPermanent(contempt.getAttachedTo());
if (attachedToPermanent != null) {
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(attachedToPermanent.getId(), game)).setText("return " + attachedToPermanent.getName() + " to owner's hand.");
AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(ability, source);
}
Effect effect = new ReturnToHandSourceEffect();
AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(ability, source);
return true;
}
return false;
}
Aggregations