diff --git a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java index 8de49bca03f..69bfcc833ca 100644 --- a/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java +++ b/forge-ai/src/main/java/forge/ai/ComputerUtilMana.java @@ -1,6 +1,7 @@ package forge.ai; import com.google.common.base.Predicate; +import com.google.common.base.Predicates; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; @@ -18,11 +19,7 @@ import forge.game.Game; import forge.game.GameActionUtil; import forge.game.ability.AbilityUtils; import forge.game.ability.ApiType; -import forge.game.card.Card; -import forge.game.card.CardCollection; -import forge.game.card.CardCollectionView; -import forge.game.card.CardLists; -import forge.game.card.CardUtil; +import forge.game.card.*; import forge.game.combat.CombatUtil; import forge.game.cost.Cost; import forge.game.cost.CostAdjustment; @@ -228,6 +225,15 @@ public class ComputerUtilMana { // creatures for mana (for example, Servant of the Conduit) continue; } + } else if (sa.getApi() == ApiType.Attach + && "AvoidPayingWithAttachTarget".equals(sa.getHostCard().getSVar("AIPaymentPreference"))) { + // For cards like Genju of the Cedars, make sure we're not attaching to the same land that will + // be tapped to pay its own cost if there's another untapped land like that available + if (ma.getHostCard().equals(sa.getTargetCard())) { + if (CardLists.filter(ai.getCardsIn(ZoneType.Battlefield), Predicates.and(CardPredicates.nameEquals(ma.getHostCard().getName()), CardPredicates.Presets.UNTAPPED)).size() > 1) { + continue; + } + } } } diff --git a/forge-gui/res/cardsfolder/g/genju_of_the_cedars.txt b/forge-gui/res/cardsfolder/g/genju_of_the_cedars.txt index cf897a40ee0..41cb8d84aee 100644 --- a/forge-gui/res/cardsfolder/g/genju_of_the_cedars.txt +++ b/forge-gui/res/cardsfolder/g/genju_of_the_cedars.txt @@ -7,5 +7,6 @@ A:AB$ Animate | Cost$ 2 | Defined$ Enchanted | Power$ 4 | Toughness$ 4 | Types$ T:Mode$ ChangesZone | ValidCard$ Card.AttachedBy | Origin$ Battlefield | Destination$ Graveyard | TriggerZones$ Battlefield | Execute$ TrigReturnOwner | OptionalDecider$ You | TriggerDescription$ When enchanted Forest is put into a graveyard, you may return CARDNAME from your graveyard to your hand. SVar:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Hand SVar:NonStackingAttachEffect:True +SVar:AIPaymentPreference:AvoidPayingWithAttachTarget SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_cedars.jpg Oracle:Enchant Forest\n{2}: Enchanted Forest becomes a 4/4 green Spirit creature until end of turn. It's still a land.\nWhen enchanted Forest is put into a graveyard, you may return Genju of the Cedars from your graveyard to your hand. diff --git a/forge-gui/res/cardsfolder/g/genju_of_the_falls.txt b/forge-gui/res/cardsfolder/g/genju_of_the_falls.txt index e40b47bcb6c..a32fb195338 100644 --- a/forge-gui/res/cardsfolder/g/genju_of_the_falls.txt +++ b/forge-gui/res/cardsfolder/g/genju_of_the_falls.txt @@ -7,5 +7,6 @@ A:AB$ Animate | Cost$ 2 | Defined$ Enchanted | Power$ 3 | Toughness$ 2 | Types$ T:Mode$ ChangesZone | ValidCard$ Card.AttachedBy | Origin$ Battlefield | Destination$ Graveyard | TriggerZones$ Battlefield | Execute$ TrigReturnOwner | OptionalDecider$ You | TriggerDescription$ When enchanted Island is put into a graveyard, you may return CARDNAME from your graveyard to your hand. SVar:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Hand SVar:NonStackingAttachEffect:True +SVar:AIPaymentPreference:AvoidPayingWithAttachTarget SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_falls.jpg Oracle:Enchant Island\n{2}: Enchanted Island becomes a 3/2 blue Spirit creature with flying until end of turn. It's still a land.\nWhen enchanted Island is put into a graveyard, you may return Genju of the Falls from your graveyard to your hand. diff --git a/forge-gui/res/cardsfolder/g/genju_of_the_fens.txt b/forge-gui/res/cardsfolder/g/genju_of_the_fens.txt index 8f639f33d55..c9375b79eac 100644 --- a/forge-gui/res/cardsfolder/g/genju_of_the_fens.txt +++ b/forge-gui/res/cardsfolder/g/genju_of_the_fens.txt @@ -8,5 +8,6 @@ T:Mode$ ChangesZone | ValidCard$ Card.AttachedBy | Origin$ Battlefield | Destina SVar:ABPump:AB$Pump | Cost$ B | Defined$ Self | NumAtt$ +1 | NumDef$ +1 | SpellDescription$ This creature gets +1/+1 until end of turn. SVar:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Hand SVar:NonStackingAttachEffect:True +SVar:AIPaymentPreference:AvoidPayingWithAttachTarget SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_fens.jpg Oracle:Enchant Swamp\n{2}: Until end of turn, enchanted Swamp becomes a 2/2 black Spirit creature with "{B}: This creature gets +1/+1 until end of turn." It's still a land.\nWhen enchanted Swamp is put into a graveyard, you may return Genju of the Fens from your graveyard to your hand. diff --git a/forge-gui/res/cardsfolder/g/genju_of_the_fields.txt b/forge-gui/res/cardsfolder/g/genju_of_the_fields.txt index a585b800cbe..aed16e3281f 100644 --- a/forge-gui/res/cardsfolder/g/genju_of_the_fields.txt +++ b/forge-gui/res/cardsfolder/g/genju_of_the_fields.txt @@ -9,6 +9,7 @@ SVar:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard SVar:PseudoLifelink:Mode$ DamageDone | ValidSource$ Card.Self | Execute$ GenjuTrigGain | TriggerZones$ Battlefield | TriggerDescription$ Whenever CARDNAME deals damage, you gain that much life. SVar:GenjuTrigGain:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ GenjuX | References$ GenjuX SVar:NonStackingAttachEffect:True +SVar:AIPaymentPreference:AvoidPayingWithAttachTarget SVar:GenjuX:TriggerCount$DamageAmount SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_fields.jpg Oracle:Enchant Plains\n{2}: Until end of turn, enchanted Plains becomes a 2/5 white Spirit creature with "Whenever this creature deals damage, its controller gains that much life." It's still a land.\nWhen enchanted Plains is put into a graveyard, you may return Genju of the Fields from your graveyard to your hand. diff --git a/forge-gui/res/cardsfolder/g/genju_of_the_spires.txt b/forge-gui/res/cardsfolder/g/genju_of_the_spires.txt index 38a96f1aca0..0f03bbf6e51 100644 --- a/forge-gui/res/cardsfolder/g/genju_of_the_spires.txt +++ b/forge-gui/res/cardsfolder/g/genju_of_the_spires.txt @@ -7,5 +7,6 @@ A:AB$ Animate | Cost$ 2 | Defined$ Enchanted | Power$ 6 | Toughness$ 1 | Types$ T:Mode$ ChangesZone | ValidCard$ Card.AttachedBy | Origin$ Battlefield | Destination$ Graveyard | TriggerZones$ Battlefield | Execute$ TrigReturnOwner | OptionalDecider$ You | TriggerDescription$ When enchanted Mountain is put into a graveyard, you may return CARDNAME from your graveyard to your hand. SVar:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Hand SVar:NonStackingAttachEffect:True +SVar:AIPaymentPreference:AvoidPayingWithAttachTarget SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_spires.jpg Oracle:Enchant Mountain\n{2}: Enchanted Mountain becomes a 6/1 red Spirit creature until end of turn. It's still a land.\nWhen enchanted Mountain is put into a graveyard, you may return Genju of the Spires from your graveyard to your hand.