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
|
// check if something would be a land
|
||||||
Card noLandLKI = CardUtil.getLKICopy(c);
|
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
|
CardCollection preList = new CardCollection(noLandLKI);
|
||||||
//noLandLKI.setZone(zoneTo);
|
checkStaticAbilities(false, Sets.newHashSet(noLandLKI), preList);
|
||||||
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));
|
|
||||||
|
|
||||||
boolean noLand = noLandLKI.isLand();
|
if(noLandLKI.isLand()) {
|
||||||
zoneTo.remove(noLandLKI);
|
|
||||||
|
|
||||||
// reset static
|
|
||||||
checkStaticAbilities(false, Sets.newHashSet(noLandLKI));
|
|
||||||
|
|
||||||
if(noLand) {
|
|
||||||
// if something would only be a land when entering the battlefield and not before
|
// if something would only be a land when entering the battlefield and not before
|
||||||
// put it into the graveyard instead
|
// put it into the graveyard instead
|
||||||
zoneTo = c.getOwner().getZone(ZoneType.Graveyard);
|
zoneTo = c.getOwner().getZone(ZoneType.Graveyard);
|
||||||
@@ -755,9 +746,9 @@ public class GameAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void checkStaticAbilities() {
|
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()) {
|
if (isCheckingStaticAbilitiesOnHold()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -816,7 +807,7 @@ public class GameAction {
|
|||||||
final CardCollectionView previouslyAffected = affectedPerAbility.get(stAb);
|
final CardCollectionView previouslyAffected = affectedPerAbility.get(stAb);
|
||||||
final CardCollectionView affectedHere;
|
final CardCollectionView affectedHere;
|
||||||
if (previouslyAffected == null) {
|
if (previouslyAffected == null) {
|
||||||
affectedHere = stAb.applyContinuousAbility(layer);
|
affectedHere = stAb.applyContinuousAbilityBefore(layer, preList);
|
||||||
if (affectedHere != null) {
|
if (affectedHere != null) {
|
||||||
affectedPerAbility.put(stAb, affectedHere);
|
affectedPerAbility.put(stAb, affectedHere);
|
||||||
}
|
}
|
||||||
@@ -926,7 +917,7 @@ public class GameAction {
|
|||||||
boolean orderedDesCreats = false;
|
boolean orderedDesCreats = false;
|
||||||
boolean orderedNoRegCreats = false;
|
boolean orderedNoRegCreats = false;
|
||||||
for (int q = 0; q < 9; q++) {
|
for (int q = 0; q < 9; q++) {
|
||||||
checkStaticAbilities(false, affectedCards);
|
checkStaticAbilities(false, affectedCards, CardCollection.EMPTY);
|
||||||
boolean checkAgain = false;
|
boolean checkAgain = false;
|
||||||
|
|
||||||
for (final Player p : game.getPlayers()) {
|
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
|
// 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
|
// trigger reset above will activate the copy's Always trigger, which needs to be triggered at
|
||||||
// this point.
|
// this point.
|
||||||
checkStaticAbilities(false, affectedCards);
|
checkStaticAbilities(false, affectedCards, CardCollection.EMPTY);
|
||||||
|
|
||||||
if (!refreeze) {
|
if (!refreeze) {
|
||||||
game.getStack().unfreezeStack();
|
game.getStack().unfreezeStack();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import forge.card.CardStateName;
|
|||||||
import forge.game.Game;
|
import forge.game.Game;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardCollection;
|
import forge.game.card.CardCollection;
|
||||||
|
import forge.game.card.CardUtil;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
import forge.game.cost.CostPayment;
|
import forge.game.cost.CostPayment;
|
||||||
import forge.game.player.Player;
|
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
|
// Rule 601.3: cast Bestow with Flash
|
||||||
// for the check the card does need to be animated
|
// for the check the card does need to be animated
|
||||||
// otherwise the StaticAbility will not found them
|
// 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
|
CardCollection preList = new CardCollection(lki);
|
||||||
card.animateBestow(false); // when animating and unanimating Bestow, do not update the view to prevent flickering
|
game.getAction().checkStaticAbilities(false, Sets.newHashSet(lki), preList);
|
||||||
game.getAction().checkStaticAbilities(false, Sets.newHashSet(card));
|
|
||||||
flash = card.hasKeyword("Flash");
|
flash = lki.hasKeyword("Flash");
|
||||||
card.unanimateBestow(false);
|
|
||||||
// need to check again to reset the Keywords and other effects
|
// 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
|
if (!(isInstant || activator.canCastSorcery() || flash
|
||||||
|
|||||||
@@ -258,11 +258,11 @@ public class StaticAbility extends CardTraitBase implements Comparable<StaticAbi
|
|||||||
buildCommonAttributes(host);
|
buildCommonAttributes(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CardCollectionView applyContinuousAbility(final StaticAbilityLayer layer) {
|
public final CardCollectionView applyContinuousAbilityBefore(final StaticAbilityLayer layer, final CardCollectionView preList) {
|
||||||
if (!shouldApplyContinuousAbility(layer, false)) {
|
if (!shouldApplyContinuousAbility(layer, false)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return StaticAbilityContinuous.applyContinuousAbility(this, layer);
|
return StaticAbilityContinuous.applyContinuousAbility(this, layer, preList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final CardCollectionView applyContinuousAbility(final StaticAbilityLayer layer, final CardCollectionView affected) {
|
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.trigger.TriggerHandler;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -67,8 +68,8 @@ public final class StaticAbilityContinuous {
|
|||||||
* @see #applyContinuousAbility(StaticAbility, CardCollectionView,
|
* @see #applyContinuousAbility(StaticAbility, CardCollectionView,
|
||||||
* StaticAbilityLayer)
|
* StaticAbilityLayer)
|
||||||
*/
|
*/
|
||||||
public static CardCollectionView applyContinuousAbility(final StaticAbility stAb, final StaticAbilityLayer layer) {
|
public static CardCollectionView applyContinuousAbility(final StaticAbility stAb, final StaticAbilityLayer layer, final CardCollectionView preList) {
|
||||||
final CardCollectionView affectedCards = getAffectedCards(stAb);
|
final CardCollectionView affectedCards = getAffectedCards(stAb, preList);
|
||||||
return applyContinuousAbility(stAb, affectedCards, layer);
|
return applyContinuousAbility(stAb, affectedCards, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,7 +826,7 @@ public final class StaticAbilityContinuous {
|
|||||||
return players;
|
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 Map<String, String> params = stAb.getMapParams();
|
||||||
final Card hostCard = stAb.getHostCard();
|
final Card hostCard = stAb.getHostCard();
|
||||||
final Game game = hostCard.getGame();
|
final Game game = hostCard.getGame();
|
||||||
@@ -837,10 +838,18 @@ public final class StaticAbilityContinuous {
|
|||||||
|
|
||||||
// non - CharacteristicDefining
|
// non - CharacteristicDefining
|
||||||
CardCollection affectedCards;
|
CardCollection affectedCards;
|
||||||
if (params.containsKey("AffectedZone")) {
|
if (preList.isEmpty()) {
|
||||||
affectedCards = new CardCollection(game.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone"))));
|
if (params.containsKey("AffectedZone")) {
|
||||||
|
affectedCards = new CardCollection(game.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone"))));
|
||||||
|
} else {
|
||||||
|
affectedCards = new CardCollection(game.getCardsIn(ZoneType.Battlefield));
|
||||||
|
}
|
||||||
} else {
|
} 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(",")) {
|
if (params.containsKey("Affected") && !params.get("Affected").contains(",")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user