Jace, Architect of Thought ult fix
package mage.cards.j;
import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageObjectReference;
@@ -24,7 +25,10 @@ import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.filter.FilterCard;
+import mage.filter.FilterPlayer;
import mage.filter.common.FilterNonlandCard;
+import mage.filter.predicate.Predicates;
+import mage.filter.predicate.other.PlayerIdPredicate;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.events.GameEvent;
@@ -32,6 +36,7 @@ import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
+import mage.target.TargetPlayer;
import mage.target.common.TargetCardInExile;
import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetOpponent;
@@ -239,8 +244,22 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
if (controller == null || sourcePermanent == null) {
return false;
}
- for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
+ List<UUID> playerList = new ArrayList<>();
+ playerList.addAll(game.getState().getPlayersInRange(controller.getId(), game));
+ List<UUID> checkList = new ArrayList<>();
+ while (!playerList.isEmpty()) {
+ FilterPlayer filter = new FilterPlayer();
+ List<PlayerIdPredicate> playerPredicates = new ArrayList<>();
+ for (UUID playerId : playerList) {
+ playerPredicates.add(new PlayerIdPredicate(playerId));
+ }
+ filter.add(Predicates.or(playerPredicates));
+ TargetPlayer targetPlayer = new TargetPlayer(1, 1, true, filter);
+ targetPlayer.setRequired(!checkList.containsAll(playerList));
+ if (controller.chooseTarget(outcome, targetPlayer, source, game)) {
+ UUID playerId = targetPlayer.getFirstTarget();
Player player = game.getPlayer(playerId);
+ if (player != null) {
String playerName = new StringBuilder(player.getLogName()).append("'s").toString();
if (source.isControlledBy(player.getId())) {
playerName = "your";
@@ -251,9 +270,23 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
Card card = player.getLibrary().remove(targetId, game);
if (card != null) {
controller.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
+ playerList.remove(playerId);
+ }
+ }
+ if (!checkList.contains(playerId)) {
+ player.shuffleLibrary(source, game); // only one shuffle per library (to prevent bad interactions with Psychogenic Probe etc.)
+ }
+ }
+ checkList.add(playerId);
+ } else {
+ break;
+ }
+ for (UUID playerId : playerList) {
+ Player player = game.getPlayer(playerId);
+ if (player == null || !player.canRespond()) {
+ playerList.remove(player);
}
}
- player.shuffleLibrary(source, game);
}
ExileZone jaceExileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
