[EOE] fix Pain for All targeting

This commit is contained in:
theelk801 2025-07-21 15:38:22 -04:00
parent a039800259
commit 33596d55b3
2 changed files with 13 additions and 21 deletions

View file

@ -5,6 +5,8 @@ import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.Optional;
/**
* Filters out the id of the enchanted object, if the source is an enchantment
*
@ -15,8 +17,13 @@ public enum AnotherEnchantedPredicate implements ObjectSourcePlayerPredicate<Per
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
Permanent enchantment = input.getSource().getSourcePermanentIfItStillExists(game);
return enchantment != null && !input.getObject().getId().equals(enchantment.getAttachedTo());
return !Optional
.ofNullable(input)
.map(ObjectSourcePlayer::getSource)
.map(source -> source.getSourcePermanentOrLKI(game))
.map(Permanent::getAttachedTo)
.filter(input.getObject().getId()::equals)
.isPresent();
}
@Override