Improve simultaneous handling with ChangeZoneAll (#4820)

Co-authored-by: TRT <>
This commit is contained in:
tool4ever
2024-03-15 09:31:04 +01:00
committed by GitHub
parent 7e37d086c6
commit f372ef87fe
10 changed files with 39 additions and 34 deletions

View File

@@ -202,16 +202,14 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
}
if (!movedCard.getZone().equals(originZone)) {
if (remember != null) {
final Card newSource = game.getCardState(source);
newSource.addRemembered(movedCard);
if (remember != null && (remember.equalsIgnoreCase("True") ||
movedCard.isValid(remember, sa.getActivatingPlayer(), source, sa))) {
if (!source.isRemembered(movedCard)) {
source.addRemembered(movedCard);
}
if (c.getMeldedWith() != null) {
Card meld = game.getCardState(c.getMeldedWith(), null);
if (meld != null) {
newSource.addRemembered(meld);
if (!source.isRemembered(meld)) {
source.addRemembered(meld);
}
@@ -220,7 +218,6 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
if (c.hasMergedCard()) {
for (final Card card : c.getMergedCards()) {
if (card == c) continue;
newSource.addRemembered(card);
if (!source.isRemembered(card)) {
source.addRemembered(card);
}
@@ -228,10 +225,10 @@ public class ChangeZoneAllEffect extends SpellAbilityEffect {
}
}
if (forget != null) {
game.getCardState(source).removeRemembered(c);
source.removeRemembered(c);
}
if (imprint != null) {
game.getCardState(source).addImprintedCard(movedCard);
source.addImprintedCard(movedCard);
}
}
}

View File

@@ -135,6 +135,10 @@ public class DigUntilEffect extends SpellAbilityEffect {
boolean sequential = digSite == ZoneType.Library && revealedDest != null && revealedDest.equals(foundDest);
CardZoneTable table = new CardZoneTable(game.copyLastStateBattlefield(), game.copyLastStateGraveyard());
CardZoneTable tableSeq = null;
if (!sequential) {
tableSeq = new CardZoneTable(table.getLastStateBattlefield(), table.getLastStateGraveyard());
}
boolean combatChanged = false;
for (final Player p : getTargetPlayers(sa)) {
@@ -148,7 +152,6 @@ public class DigUntilEffect extends SpellAbilityEffect {
CardCollection revealed = new CardCollection();
final PlayerZone library = p.getZone(digSite);
final int maxToDig = maxRevealed != null ? maxRevealed : library.size();
for (int i = 0; i < maxToDig; i++) {
@@ -202,7 +205,9 @@ public class DigUntilEffect extends SpellAbilityEffect {
foundDest = optionalNoDestination;
}
CardZoneTable tableSeq = new CardZoneTable(table.getLastStateBattlefield(), table.getLastStateGraveyard());
if (sequential) {
tableSeq = new CardZoneTable(table.getLastStateBattlefield(), table.getLastStateGraveyard());
}
Map<AbilityKey, Object> moveParams = AbilityKey.newMap();
AbilityKey.addCardZoneTableParams(moveParams, tableSeq);
@@ -241,7 +246,9 @@ public class DigUntilEffect extends SpellAbilityEffect {
game.getAction().moveTo(foundDest, c, foundLibPos, sa, moveParams);
}
tableSeq.triggerChangesZoneAll(game, sa);
if (sequential) {
tableSeq.triggerChangesZoneAll(game, sa);
}
}
revealed.removeAll(found);
}
@@ -279,9 +286,7 @@ public class DigUntilEffect extends SpellAbilityEffect {
Map<AbilityKey, Object> moveParams = AbilityKey.newMap();
AbilityKey.addCardZoneTableParams(moveParams, table);
final Iterator<Card> itr = revealed.iterator();
while (itr.hasNext()) {
final Card c = itr.next();
for (Card c : revealed) {
game.getAction().moveTo(finalDest, c, finalPos, sa, moveParams);
}
}
@@ -294,6 +299,9 @@ public class DigUntilEffect extends SpellAbilityEffect {
game.updateCombatForView();
game.fireEvent(new GameEventCombatChanged());
}
if (!sequential) {
tableSeq.triggerChangesZoneAll(game, sa);
}
table.triggerChangesZoneAll(game, sa);
}