Fix "becomes the target of" logic to check all modes (#12452)

* check all targets from all modes for getTargetingStackObject

* update logic related to a97dec3
This commit is contained in:
xenohedron 2024-06-11 00:58:12 -04:00 committed by GitHub
parent e209ce1c97
commit fc21365847
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 94 additions and 6 deletions

View file

@ -5,6 +5,7 @@ import mage.abilities.condition.Condition;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.stack.StackObject;
import mage.util.CardUtil;
import java.util.Objects;
@ -25,9 +26,8 @@ public class SourceTargetsPermanentCondition implements Condition {
if (stackObject == null) {
return false;
}
return stackObject.getStackAbility().getTargets()
return CardUtil.getAllSelectedTargets(stackObject.getStackAbility(), game)
.stream()
.flatMap(t -> t.getTargets().stream())
.map(game::getPermanentOrLKIBattlefield)
.filter(Objects::nonNull)
.anyMatch(p -> filter.match(p, source.getControllerId(), source, game));

View file

@ -1054,10 +1054,8 @@ public final class CardUtil {
if (stackAbility == null || !stackAbility.getSourceId().equals(event.getSourceId())) {
continue;
}
for (Target target : stackAbility.getTargets()) {
if (target.getTargets().contains(event.getTargetId())) {
return stackObject;
}
if (CardUtil.getAllSelectedTargets(stackAbility, game).contains(event.getTargetId())) {
return stackObject;
}
}
return null;