[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

@ -9,9 +9,9 @@ import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.common.FilterAnyTarget;
import mage.filter.common.FilterPermanentOrPlayer; import mage.filter.common.FilterPermanentOrPlayer;
import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.permanent.AnotherEnchantedPredicate;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
@ -26,10 +26,10 @@ import java.util.UUID;
*/ */
public final class PainForAll extends CardImpl { public final class PainForAll extends CardImpl {
private static final FilterPermanentOrPlayer filter = new FilterPermanentOrPlayer("any other target"); private static final FilterPermanentOrPlayer filter = new FilterAnyTarget("any other target");
static { static {
filter.getPermanentFilter().add(PainForAllPredicate.instance); filter.getPermanentFilter().add(AnotherEnchantedPredicate.instance);
} }
public PainForAll(UUID ownerId, CardSetInfo setInfo) { public PainForAll(UUID ownerId, CardSetInfo setInfo) {
@ -64,21 +64,6 @@ public final class PainForAll extends CardImpl {
} }
} }
enum PainForAllPredicate implements ObjectSourcePlayerPredicate<Permanent> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
return Optional
.ofNullable(input)
.map(ObjectSourcePlayer::getSource)
.map(source -> source.getSourcePermanentOrLKI(game))
.map(Permanent::getAttachedTo)
.filter(permanentId -> !permanentId.equals(input.getObject().getId()))
.isPresent();
}
}
class PainForAllFirstEffect extends OneShotEffect { class PainForAllFirstEffect extends OneShotEffect {
PainForAllFirstEffect() { PainForAllFirstEffect() {

View file

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