- Genju of the X cycle of cards AI: attempt to avoid tapping the targeted card for mana if there's another source like that available (might be further improved later by detecting the actual mana type and the sources of that type that are open, after which the special AI parameter SVar might no longer be necessary).

This commit is contained in:
Agetian
2017-08-26 18:01:03 +00:00
parent 586abb5466
commit cdb6d10519
6 changed files with 16 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
package forge.ai; package forge.ai;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap; import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -18,11 +19,7 @@ import forge.game.Game;
import forge.game.GameActionUtil; import forge.game.GameActionUtil;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
import forge.game.ability.ApiType; import forge.game.ability.ApiType;
import forge.game.card.Card; import forge.game.card.*;
import forge.game.card.CardCollection;
import forge.game.card.CardCollectionView;
import forge.game.card.CardLists;
import forge.game.card.CardUtil;
import forge.game.combat.CombatUtil; import forge.game.combat.CombatUtil;
import forge.game.cost.Cost; import forge.game.cost.Cost;
import forge.game.cost.CostAdjustment; import forge.game.cost.CostAdjustment;
@@ -228,6 +225,15 @@ public class ComputerUtilMana {
// creatures for mana (for example, Servant of the Conduit) // creatures for mana (for example, Servant of the Conduit)
continue; 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;
}
}
} }
} }

View File

@@ -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. 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:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Hand
SVar:NonStackingAttachEffect:True SVar:NonStackingAttachEffect:True
SVar:AIPaymentPreference:AvoidPayingWithAttachTarget
SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_cedars.jpg 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. 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.

View File

@@ -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. 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:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Hand
SVar:NonStackingAttachEffect:True SVar:NonStackingAttachEffect:True
SVar:AIPaymentPreference:AvoidPayingWithAttachTarget
SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_falls.jpg 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. 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.

View File

@@ -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: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:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Hand
SVar:NonStackingAttachEffect:True SVar:NonStackingAttachEffect:True
SVar:AIPaymentPreference:AvoidPayingWithAttachTarget
SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_fens.jpg 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. 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.

View File

@@ -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: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:GenjuTrigGain:AB$GainLife | Cost$ 0 | Defined$ You | LifeAmount$ GenjuX | References$ GenjuX
SVar:NonStackingAttachEffect:True SVar:NonStackingAttachEffect:True
SVar:AIPaymentPreference:AvoidPayingWithAttachTarget
SVar:GenjuX:TriggerCount$DamageAmount SVar:GenjuX:TriggerCount$DamageAmount
SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_fields.jpg 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. 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.

View File

@@ -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. 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:TrigReturnOwner:AB$ChangeZone | Cost$ 0 | Defined$ Self | Origin$ Graveyard | Destination$ Hand
SVar:NonStackingAttachEffect:True SVar:NonStackingAttachEffect:True
SVar:AIPaymentPreference:AvoidPayingWithAttachTarget
SVar:Picture:http://www.wizards.com/global/images/magic/general/genju_of_the_spires.jpg 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. 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.