- Added an ai check svar to Sheltered Valley so that it won't play it if it already has another one on the battlefield

- AiController.getLandsToPlay will now check NeedsToPlayVar and filter out relevant cards
This commit is contained in:
moomarc
2013-02-07 05:47:08 +00:00
parent 5a9838c6d1
commit aceff2002d
2 changed files with 25 additions and 1 deletions

View File

@@ -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

View File

@@ -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;
/**
* <p>
@@ -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<Card> list = player.getCardsIn(ZoneType.Battlefield);
if (Iterables.any(list, CardPredicates.nameEquals(c.getName()))) {