mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
StaticAbilityContinuous: use preList to check defined list other than zones
This commit is contained in:
@@ -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.<Card>newHashSet());
|
||||
checkStaticAbilities(true, Sets.<Card>newHashSet(), CardCollection.EMPTY);
|
||||
}
|
||||
public final void checkStaticAbilities(final boolean runEvents, final Set<Card> affectedCards) {
|
||||
public final void checkStaticAbilities(final boolean runEvents, final Set<Card> 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();
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -258,11 +258,11 @@ public class StaticAbility extends CardTraitBase implements Comparable<StaticAbi
|
||||
buildCommonAttributes(host);
|
||||
}
|
||||
|
||||
public final CardCollectionView applyContinuousAbility(final StaticAbilityLayer layer) {
|
||||
public final CardCollectionView applyContinuousAbilityBefore(final StaticAbilityLayer layer, final CardCollectionView preList) {
|
||||
if (!shouldApplyContinuousAbility(layer, false)) {
|
||||
return null;
|
||||
}
|
||||
return StaticAbilityContinuous.applyContinuousAbility(this, layer);
|
||||
return StaticAbilityContinuous.applyContinuousAbility(this, layer, preList);
|
||||
}
|
||||
|
||||
public final CardCollectionView applyContinuousAbility(final StaticAbilityLayer layer, final CardCollectionView affected) {
|
||||
|
||||
@@ -41,6 +41,7 @@ import forge.game.trigger.Trigger;
|
||||
import forge.game.trigger.TriggerHandler;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.TextUtil;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
@@ -67,8 +68,8 @@ public final class StaticAbilityContinuous {
|
||||
* @see #applyContinuousAbility(StaticAbility, CardCollectionView,
|
||||
* StaticAbilityLayer)
|
||||
*/
|
||||
public static CardCollectionView applyContinuousAbility(final StaticAbility stAb, final StaticAbilityLayer layer) {
|
||||
final CardCollectionView affectedCards = getAffectedCards(stAb);
|
||||
public static CardCollectionView applyContinuousAbility(final StaticAbility stAb, final StaticAbilityLayer layer, final CardCollectionView preList) {
|
||||
final CardCollectionView affectedCards = getAffectedCards(stAb, preList);
|
||||
return applyContinuousAbility(stAb, affectedCards, layer);
|
||||
}
|
||||
|
||||
@@ -825,7 +826,7 @@ public final class StaticAbilityContinuous {
|
||||
return players;
|
||||
}
|
||||
|
||||
private static CardCollectionView getAffectedCards(final StaticAbility stAb) {
|
||||
private static CardCollectionView getAffectedCards(final StaticAbility stAb, final CardCollectionView preList) {
|
||||
final Map<String, String> 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(",")) {
|
||||
|
||||
Reference in New Issue
Block a user