mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 22:12:03 -08:00
Merge pull request #5366 from Zzooouhh/Zzooouhh-jace
Jace, Architect of Thought ultimate fix (fixes #5357)
This commit is contained in:
commit
eb02409f19
1 changed files with 53 additions and 13 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
package mage.cards.j;
|
package mage.cards.j;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
|
|
@ -24,7 +26,10 @@ import mage.constants.SubType;
|
||||||
import mage.constants.SuperType;
|
import mage.constants.SuperType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
|
import mage.filter.FilterPlayer;
|
||||||
import mage.filter.common.FilterNonlandCard;
|
import mage.filter.common.FilterNonlandCard;
|
||||||
|
import mage.filter.predicate.Predicates;
|
||||||
|
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||||
import mage.game.ExileZone;
|
import mage.game.ExileZone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
@ -32,6 +37,7 @@ import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetCard;
|
import mage.target.TargetCard;
|
||||||
|
import mage.target.TargetPlayer;
|
||||||
import mage.target.common.TargetCardInExile;
|
import mage.target.common.TargetCardInExile;
|
||||||
import mage.target.common.TargetCardInLibrary;
|
import mage.target.common.TargetCardInLibrary;
|
||||||
import mage.target.common.TargetOpponent;
|
import mage.target.common.TargetOpponent;
|
||||||
|
|
@ -239,23 +245,57 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
|
||||||
if (controller == null || sourcePermanent == null) {
|
if (controller == null || sourcePermanent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
List<UUID> playerList = new ArrayList<>();
|
||||||
Player player = game.getPlayer(playerId);
|
playerList.addAll(game.getState().getPlayersInRange(controller.getId(), game));
|
||||||
String playerName = new StringBuilder(player.getLogName()).append("'s").toString();
|
Set<UUID> checkList = new HashSet<>();
|
||||||
if (source.isControlledBy(player.getId())) {
|
while (!playerList.isEmpty()) {
|
||||||
playerName = "your";
|
FilterPlayer filter = new FilterPlayer();
|
||||||
|
List<PlayerIdPredicate> playerPredicates = new ArrayList<>();
|
||||||
|
for (UUID playerId : playerList) {
|
||||||
|
playerPredicates.add(new PlayerIdPredicate(playerId));
|
||||||
}
|
}
|
||||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard(new StringBuilder("nonland card from ").append(playerName).append(" library").toString()));
|
filter.add(Predicates.or(playerPredicates));
|
||||||
if (controller.searchLibrary(target, game, playerId)) {
|
TargetPlayer targetPlayer = new TargetPlayer(1, 1, true, filter);
|
||||||
UUID targetId = target.getFirstTarget();
|
targetPlayer.setRequired(!checkList.containsAll(playerList));
|
||||||
Card card = player.getLibrary().remove(targetId, game);
|
if (controller.chooseTarget(outcome, targetPlayer, source, game)) {
|
||||||
if (card != null) {
|
UUID playerId = targetPlayer.getFirstTarget();
|
||||||
controller.moveCardToExileWithInfo(card, CardUtil.getCardExileZoneId(game, source), sourcePermanent.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null) {
|
||||||
|
String playerName = new StringBuilder(player.getLogName()).append("'s").toString();
|
||||||
|
if (source.isControlledBy(player.getId())) {
|
||||||
|
playerName = "your";
|
||||||
|
}
|
||||||
|
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard(new StringBuilder("nonland card from ").append(playerName).append(" library").toString()));
|
||||||
|
if (controller.searchLibrary(target, game, playerId, !checkList.contains(playerId))) {
|
||||||
|
checkList.add(playerId);
|
||||||
|
UUID targetId = target.getFirstTarget();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
playerList.remove(playerId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
playerList.remove(playerId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (UUID playerId : playerList) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player == null || !player.canRespond()) {
|
||||||
|
playerList.remove(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.shuffleLibrary(source, game);
|
|
||||||
}
|
}
|
||||||
|
for (UUID playerId : checkList) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null) {
|
||||||
|
player.shuffleLibrary(source, game);
|
||||||
|
}
|
||||||
|
}
|
||||||
ExileZone jaceExileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
ExileZone jaceExileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
|
||||||
if (jaceExileZone == null) {
|
if (jaceExileZone == null) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue