diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index a6f0f5490aa..8ccd14c2bed 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -258,22 +258,13 @@ public class GameAction { } // check if something would be a land Card noLandLKI = CardUtil.getLKICopy(c); + // this check needs to check if this card would be on the battlefield + noLandLKI.setLastKnownZone(zoneTo); - //setZone is not enough - //noLandLKI.setZone(zoneTo); - noLandLKI.setImmutable(true); // immu doesn't trigger Zone - zoneTo.add(noLandLKI); - - noLandLKI.setImmutable(false); // but need to remove that or Static doesn't find it - checkStaticAbilities(false, Sets.newHashSet(noLandLKI)); + CardCollection preList = new CardCollection(noLandLKI); + checkStaticAbilities(false, Sets.newHashSet(noLandLKI), preList); - boolean noLand = noLandLKI.isLand(); - zoneTo.remove(noLandLKI); - - // reset static - checkStaticAbilities(false, Sets.newHashSet(noLandLKI)); - - if(noLand) { + if(noLandLKI.isLand()) { // if something would only be a land when entering the battlefield and not before // put it into the graveyard instead zoneTo = c.getOwner().getZone(ZoneType.Graveyard); @@ -755,9 +746,9 @@ public class GameAction { } public final void checkStaticAbilities() { - checkStaticAbilities(true, Sets.newHashSet()); + checkStaticAbilities(true, Sets.newHashSet(), CardCollection.EMPTY); } - public final void checkStaticAbilities(final boolean runEvents, final Set affectedCards) { + public final void checkStaticAbilities(final boolean runEvents, final Set affectedCards, final CardCollectionView preList) { if (isCheckingStaticAbilitiesOnHold()) { return; } @@ -816,7 +807,7 @@ public class GameAction { final CardCollectionView previouslyAffected = affectedPerAbility.get(stAb); final CardCollectionView affectedHere; if (previouslyAffected == null) { - affectedHere = stAb.applyContinuousAbility(layer); + affectedHere = stAb.applyContinuousAbilityBefore(layer, preList); if (affectedHere != null) { affectedPerAbility.put(stAb, affectedHere); } @@ -926,7 +917,7 @@ public class GameAction { boolean orderedDesCreats = false; boolean orderedNoRegCreats = false; for (int q = 0; q < 9; q++) { - checkStaticAbilities(false, affectedCards); + checkStaticAbilities(false, affectedCards, CardCollection.EMPTY); boolean checkAgain = false; for (final Player p : game.getPlayers()) { @@ -1068,7 +1059,7 @@ public class GameAction { // if the legendary rule was invoked on a Thespian's Stage that just copied Dark Depths, the // trigger reset above will activate the copy's Always trigger, which needs to be triggered at // this point. - checkStaticAbilities(false, affectedCards); + checkStaticAbilities(false, affectedCards, CardCollection.EMPTY); if (!refreeze) { game.getStack().unfreezeStack(); diff --git a/forge-game/src/main/java/forge/game/spellability/Spell.java b/forge-game/src/main/java/forge/game/spellability/Spell.java index e0aacd8fd22..86ba567e986 100644 --- a/forge-game/src/main/java/forge/game/spellability/Spell.java +++ b/forge-game/src/main/java/forge/game/spellability/Spell.java @@ -23,6 +23,7 @@ import forge.card.CardStateName; import forge.game.Game; import forge.game.card.Card; import forge.game.card.CardCollection; +import forge.game.card.CardUtil; import forge.game.cost.Cost; import forge.game.cost.CostPayment; import forge.game.player.Player; @@ -93,14 +94,21 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable // Rule 601.3: cast Bestow with Flash // for the check the card does need to be animated // otherwise the StaticAbility will not found them + + Card lki = card.isLKI() ? card : CardUtil.getLKICopy(card); + + lki.animateBestow(false); - // LKI copy does not work, need to check for the Static Abilities which might effect this card - card.animateBestow(false); // when animating and unanimating Bestow, do not update the view to prevent flickering - game.getAction().checkStaticAbilities(false, Sets.newHashSet(card)); - flash = card.hasKeyword("Flash"); - card.unanimateBestow(false); + CardCollection preList = new CardCollection(lki); + game.getAction().checkStaticAbilities(false, Sets.newHashSet(lki), preList); + + flash = lki.hasKeyword("Flash"); + // need to check again to reset the Keywords and other effects - game.getAction().checkStaticAbilities(false, Sets.newHashSet(card)); + if (card.isLKI()) { + lki.unanimateBestow(false); + game.getAction().checkStaticAbilities(false, Sets.newHashSet(lki), preList); + } } if (!(isInstant || activator.canCastSorcery() || flash diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbility.java b/forge-game/src/main/java/forge/game/staticability/StaticAbility.java index 6b868ec04e6..39f8be88ff9 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbility.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbility.java @@ -258,11 +258,11 @@ public class StaticAbility extends CardTraitBase implements Comparable params = stAb.getMapParams(); final Card hostCard = stAb.getHostCard(); final Game game = hostCard.getGame(); @@ -837,10 +838,18 @@ public final class StaticAbilityContinuous { // non - CharacteristicDefining CardCollection affectedCards; - if (params.containsKey("AffectedZone")) { - affectedCards = new CardCollection(game.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone")))); + if (preList.isEmpty()) { + if (params.containsKey("AffectedZone")) { + affectedCards = new CardCollection(game.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone")))); + } else { + affectedCards = new CardCollection(game.getCardsIn(ZoneType.Battlefield)); + } } else { - affectedCards = new CardCollection(game.getCardsIn(ZoneType.Battlefield)); + if (params.containsKey("AffectedZone")) { + affectedCards = CardLists.filter(preList, CardPredicates.inZone(ZoneType.listValueOf(params.get("AffectedZone")))); + } else { + affectedCards = CardLists.filter(preList, CardPredicates.inZone(ZoneType.Battlefield)); + } } if (params.containsKey("Affected") && !params.get("Affected").contains(",")) {