mirror of
https://github.com/correl/mage.git
synced 2025-01-12 03:00:13 +00:00
Jace, Architect of Thought ult fix
This commit is contained in:
parent
4e640dc8ab
commit
297b543630
1 changed files with 45 additions and 12 deletions
|
@ -2,6 +2,7 @@
|
|||
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,21 +244,49 @@ class JaceArchitectOfThoughtEffect3 extends OneShotEffect {
|
|||
if (controller == null || sourcePermanent == null) {
|
||||
return false;
|
||||
}
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
String playerName = new StringBuilder(player.getLogName()).append("'s").toString();
|
||||
if (source.isControlledBy(player.getId())) {
|
||||
playerName = "your";
|
||||
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));
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard(new StringBuilder("nonland card from ").append(playerName).append(" library").toString()));
|
||||
if (controller.searchLibrary(target, game, 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);
|
||||
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";
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard(new StringBuilder("nonland card from ").append(playerName).append(" library").toString()));
|
||||
if (controller.searchLibrary(target, game, 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);
|
||||
}
|
||||
}
|
||||
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));
|
||||
|
|
Loading…
Reference in a new issue