From 466eac71a1aacb46e0cf1e1ec09215da742befc0 Mon Sep 17 00:00:00 2001 From: Hanmac Date: Tue, 23 Jan 2018 21:32:45 +0100 Subject: [PATCH] Spell: Bestow now works with StaticAbilities again --- .../java/forge/game/spellability/Spell.java | 3 +-- .../spellability/SpellAbilityRestriction.java | 5 +++++ .../StaticAbilityContinuous.java | 22 +++++++++++-------- 3 files changed, 19 insertions(+), 11 deletions(-) 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 29e7aba3476..86ba567e986 100644 --- a/forge-game/src/main/java/forge/game/spellability/Spell.java +++ b/forge-game/src/main/java/forge/game/spellability/Spell.java @@ -100,8 +100,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable lki.animateBestow(false); CardCollection preList = new CardCollection(lki); - // FIXME: make this work with preList so that it doesn't cause game state corruption with pump effects (see issue #131) - game.getAction().checkStaticAbilities(false, Sets.newHashSet(lki), /*preList*/new CardCollection()); + game.getAction().checkStaticAbilities(false, Sets.newHashSet(lki), preList); flash = lki.hasKeyword("Flash"); diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java index 36bd023fbef..168b52f4605 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityRestriction.java @@ -217,6 +217,11 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { // for Bestow need to check the animated State if (sa.isSpell() && sa.hasParam("Bestow")) { + // already bestowed or in battlefield, no need to check for spell + if (c.isBestowed() || c.isInZone(ZoneType.Battlefield)) { + return false; + } + if (!c.isLKI()) { cp = CardUtil.getLKICopy(c); } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java index 316ab6a4e46..324df8096c0 100644 --- a/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java @@ -829,19 +829,23 @@ public final class StaticAbilityContinuous { } // non - CharacteristicDefining - CardCollection affectedCards; - if (preList.isEmpty()) { + CardCollection affectedCards = new CardCollection(); + + // add preList in addition to the normal affected cards + // need to add before game cards to have preference over them + if (!preList.isEmpty()) { if (params.containsKey("AffectedZone")) { - affectedCards = new CardCollection(game.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone")))); + affectedCards.addAll(CardLists.filter(preList, CardPredicates.inZone( + ZoneType.listValueOf(params.get("AffectedZone"))))); } else { - affectedCards = new CardCollection(game.getCardsIn(ZoneType.Battlefield)); + affectedCards.addAll(CardLists.filter(preList, CardPredicates.inZone(ZoneType.Battlefield))); } + } + + if (params.containsKey("AffectedZone")) { + affectedCards.addAll(game.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone")))); } else { - if (params.containsKey("AffectedZone")) { - affectedCards = CardLists.filter(preList, CardPredicates.inZone(ZoneType.listValueOf(params.get("AffectedZone")))); - } else { - affectedCards = CardLists.filter(preList, CardPredicates.inZone(ZoneType.Battlefield)); - } + affectedCards.addAll(game.getCardsIn(ZoneType.Battlefield)); } if (params.containsKey("Affected") && !params.get("Affected").contains(",")) {