diff --git a/res/cardsfolder/s/sheltered_valley.txt b/res/cardsfolder/s/sheltered_valley.txt index 801447105bf..20b88680362 100644 --- a/res/cardsfolder/s/sheltered_valley.txt +++ b/res/cardsfolder/s/sheltered_valley.txt @@ -7,7 +7,9 @@ SVar:SacBeforeETB:DB$ SacrificeAll | ValidCards$ Permanent.YouCtrl+namedSheltere SVar:MoveToBattlefield:DB$ ChangeZone | Origin$ All | Destination$ Battlefield | Defined$ ReplacedCard A:AB$ Mana | Cost$ T | Produced$ 1 | SpellDescription$ Add 1 to your mana pool. T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | IsPresent$ Land.YouCtrl | PresentCompare$ LE3 | Execute$ TrigGainLife | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of your upkeep, if you control three or fewer lands, you gain 1 life. -SVar:TrigGainLife:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 1 +SVar:TrigGainLife:AB$ GainLife | Cost$ 0 | Defined$ You | LifeAmount$ 1 +SVar:NeedsToPlayVar:OnlyOne EQ0 +SVar:OnlyOne:Count$Valid Permanent.YouCtrl+namedSheltered Valley SVar:Rarity:Rare SVar:Picture:http://wizards.com/global/images/magic/general/sheltered_valley.jpg SetInfo:ALL|Rare|http://magiccards.info/scans/en/ai/187.jpg diff --git a/src/main/java/forge/game/ai/AiController.java b/src/main/java/forge/game/ai/AiController.java index 2604bf401c7..633cf5739a5 100644 --- a/src/main/java/forge/game/ai/AiController.java +++ b/src/main/java/forge/game/ai/AiController.java @@ -45,6 +45,7 @@ import forge.game.player.AIPlayer; import forge.game.player.Player; import forge.game.zone.ZoneType; import forge.util.Aggregates; +import forge.util.Expressions; /** *

@@ -278,6 +279,27 @@ public class AiController { return false; } } + if (c.getSVar("NeedsToPlayVar").length() > 0) { + final String needsToPlay = c.getSVar("NeedsToPlayVar"); + int x = 0; + int y = 0; + String sVar = needsToPlay.split(" ")[0]; + String comparator = needsToPlay.split(" ")[1]; + String compareTo = comparator.substring(2); + try { + x = Integer.parseInt(sVar); + } catch (final NumberFormatException e) { + x = CardFactoryUtil.xCount(c, c.getSVar(sVar)); + } + try { + y = Integer.parseInt(compareTo); + } catch (final NumberFormatException e) { + y = CardFactoryUtil.xCount(c, c.getSVar(compareTo)); + } + if (!Expressions.compare(x, comparator, y)) { + return false; + } + } if (c.isType("Legendary") && !c.getName().equals("Flagstones of Trokair")) { final List list = player.getCardsIn(ZoneType.Battlefield); if (Iterables.any(list, CardPredicates.nameEquals(c.getName()))) {