@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
StackObject stackObject = game.getStack().getStackObject(source.getId());
Spell spell = (Spell) stackObject;
if (spell == null) {
return false;
}
spell = spell.copySpell(source.getControllerId());
Effect epicEffect = null;
for (Effect effect : spell.getSpellAbility().getEffects()) {
if (effect instanceof EpicEffect) {
epicEffect = effect;
break;
}
}
spell.getSpellAbility().getEffects().remove(epicEffect);
DelayedTriggeredAbility ability = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(new EpicPushEffect(spell, rule), Duration.EndOfGame, false);
game.addDelayedTriggeredAbility(ability, source);
game.addEffect(new EpicReplacementEffect(), source);
return true;
}
return false;
}