return new RescueFromTheUnderworldCreateDelayedTriggeredAbilityEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
DelayedTriggeredAbility delayedAbility = (DelayedTriggeredAbility) ability.copy();
delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId());
delayedAbility.getTargets().addAll(source.getTargets());
for(Effect effect : delayedAbility.getEffects()) {
effect.getTargetPointer().init(game, source);
}
// add the sacrificed creature as target
for (Cost cost :source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
TargetCardInGraveyard target = new TargetCardInGraveyard();
for(Permanent permanent : sacCost.getPermanents()) {
target.add(permanent.getId(), game);
delayedAbility.getTargets().add(target);
}
}
}
game.addDelayedTriggeredAbility(delayedAbility);