Merge branch 'master' into 'master'

Better AI for SpecificCard Auras

See merge request core-developers/forge!4660
This commit is contained in:
Michael Kamensky
2021-05-05 17:47:31 +00:00
8 changed files with 12 additions and 23 deletions

View File

@@ -734,17 +734,15 @@ public class AttachAi extends SpellAbilityAi {
*/ */
private static Card attachAISpecificCardPreference(final SpellAbility sa, final List<Card> list, final boolean mandatory, private static Card attachAISpecificCardPreference(final SpellAbility sa, final List<Card> list, final boolean mandatory,
final Card attachSource) { final Card attachSource) {
// I know this isn't much better than Hardcoding, but some cards need it for now
final Player ai = sa.getActivatingPlayer(); final Player ai = sa.getActivatingPlayer();
final String sourceName = ComputerUtilAbility.getAbilitySourceName(sa); final String sourceName = ComputerUtilAbility.getAbilitySourceName(sa);
Card chosen = null; Card chosen = null;
if ("Guilty Conscience".equals(sourceName)) { if ("Guilty Conscience".equals(sourceName)) {
chosen = SpecialCardAi.GuiltyConscience.getBestAttachTarget(ai, sa, list); chosen = SpecialCardAi.GuiltyConscience.getBestAttachTarget(ai, sa, list);
} else if ("Bonds of Faith".equals(sourceName)) { } else if (sa.hasParam("AIValid")) {
chosen = doPumpOrCurseAILogic(ai, sa, list, "Human"); // TODO: Make the AI recognize which cards to pump based on the card's abilities alone
} else if ("Clutch of Undeath".equals(sourceName)) { chosen = doPumpOrCurseAILogic(ai, sa, list, sa.getParam("AIValid"));
chosen = doPumpOrCurseAILogic(ai, sa, list, "Zombie");
} }
// If Mandatory (brought directly into play without casting) gotta // If Mandatory (brought directly into play without casting) gotta
@@ -1699,7 +1697,7 @@ public class AttachAi extends SpellAbilityAi {
if (!c.getController().equals(ai)) { if (!c.getController().equals(ai)) {
return false; return false;
} }
return c.getType().hasCreatureType(type); return c.isValid(type, ai, sa.getHostCard(), sa);
} }
}); });
List<Card> oppNonType = CardLists.filter(list, new Predicate<Card>() { List<Card> oppNonType = CardLists.filter(list, new Predicate<Card>() {
@@ -1709,7 +1707,7 @@ public class AttachAi extends SpellAbilityAi {
if (c.getController().equals(ai)) { if (c.getController().equals(ai)) {
return false; return false;
} }
return !c.getType().hasCreatureType(type) && !ComputerUtilCard.isUselessCreature(ai, c); return !c.isValid(type, ai, sa.getHostCard(), sa) && !ComputerUtilCard.isUselessCreature(ai, c);
} }
}); });

View File

@@ -2,8 +2,7 @@ Name:Armament of Nyx
ManaCost:2 W ManaCost:2 W
Types:Enchantment Aura Types:Enchantment Aura
K:Enchant creature K:Enchant creature
A:SP$ Attach | Cost$ 2 W | ValidTgts$ Creature | AILogic$ Curse | AITgts$ Creature.nonEnchantment+OppCtrl A:SP$ Attach | Cost$ 2 W | ValidTgts$ Creature | AILogic$ SpecificCard | AIValid$ Enchantment
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Enchantment | AddKeyword$ Double Strike | Description$ Enchanted creature has double strike as long as it's an enchantment. Otherwise, prevent all damage that would be dealt by enchanted creature. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Enchantment | AddKeyword$ Double Strike | Description$ Enchanted creature has double strike as long as it's an enchantment. Otherwise, prevent all damage that would be dealt by enchanted creature.
R:Event$ DamageDone | Prevent$ True | ValidSource$ Creature.EnchantedBy+nonEnchantment | Secondary$ True | Description$ Otherwise, prevent all damage that would be dealt by enchanted creature. R:Event$ DamageDone | Prevent$ True | ValidSource$ Creature.EnchantedBy+nonEnchantment | Secondary$ True | Description$ Otherwise, prevent all damage that would be dealt by enchanted creature.
SVar:Picture:http://www.wizards.com/global/images/magic/general/armament_of_nyx.jpg
Oracle:Enchant creature\nEnchanted creature has double strike as long as it's an enchantment. Otherwise, prevent all damage that would be dealt by enchanted creature. (A creature with double strike deals both first-strike and regular combat damage.) Oracle:Enchant creature\nEnchanted creature has double strike as long as it's an enchantment. Otherwise, prevent all damage that would be dealt by enchanted creature. (A creature with double strike deals both first-strike and regular combat damage.)

View File

@@ -2,8 +2,7 @@ Name:Bonds of Faith
ManaCost:1 W ManaCost:1 W
Types:Enchantment Aura Types:Enchantment Aura
K:Enchant creature K:Enchant creature
A:SP$ Attach | Cost$ 1 W | ValidTgts$ Creature | AILogic$ SpecificCard A:SP$ Attach | Cost$ 1 W | ValidTgts$ Creature | AILogic$ SpecificCard | AIValid$ Human
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Human | AddPower$ 2 | AddToughness$ 2 | Description$ Enchanted creature gets +2/+2 as long as it's a Human. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Human | AddPower$ 2 | AddToughness$ 2 | Description$ Enchanted creature gets +2/+2 as long as it's a Human.
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonHuman | AddHiddenKeyword$ CARDNAME can't attack or block. | Description$ Otherwise, it can't attack or block. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonHuman | AddHiddenKeyword$ CARDNAME can't attack or block. | Description$ Otherwise, it can't attack or block.
SVar:Picture:http://www.wizards.com/global/images/magic/general/bonds_of_faith.jpg
Oracle:Enchant creature\nEnchanted creature gets +2/+2 as long as it's a Human. Otherwise, it can't attack or block. Oracle:Enchant creature\nEnchanted creature gets +2/+2 as long as it's a Human. Otherwise, it can't attack or block.

View File

@@ -2,9 +2,8 @@ Name:Clutch of Undeath
ManaCost:3 B B ManaCost:3 B B
Types:Enchantment Aura Types:Enchantment Aura
K:Enchant creature K:Enchant creature
A:SP$ Attach | Cost$ 3 B B | ValidTgts$ Creature | AILogic$ SpecificCard A:SP$ Attach | Cost$ 3 B B | ValidTgts$ Creature | AILogic$ SpecificCard | AIValid$ Zombie
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Zombie | AddPower$ 3 | AddToughness$ 3 | Description$ Enchanted creature gets +3/+3 as long as it's a Zombie. Otherwise, it gets -3/-3. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Zombie | AddPower$ 3 | AddToughness$ 3 | Description$ Enchanted creature gets +3/+3 as long as it's a Zombie. Otherwise, it gets -3/-3.
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonZombie | AddPower$ -3 | AddToughness$ -3 S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonZombie | AddPower$ -3 | AddToughness$ -3
DeckNeeds:Type$Zombie DeckNeeds:Type$Zombie
SVar:Picture:http://www.wizards.com/global/images/magic/general/clutch_of_undeath.jpg
Oracle:Enchant creature\nEnchanted creature gets +3/+3 as long as it's a Zombie. Otherwise, it gets -3/-3. Oracle:Enchant creature\nEnchanted creature gets +3/+3 as long as it's a Zombie. Otherwise, it gets -3/-3.

View File

@@ -2,8 +2,7 @@ Name:Nyx Infusion
ManaCost:2 B ManaCost:2 B
Types:Enchantment Aura Types:Enchantment Aura
K:Enchant creature K:Enchant creature
A:SP$ Attach | Cost$ 2 B | ValidTgts$ Creature | AILogic$ Curse | AITgts$ Creature.nonEnchantment+OppCtrl A:SP$ Attach | Cost$ 2 B | ValidTgts$ Creature | AILogic$ SpecificCard | AIValid$ Enchantment
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Enchantment | AddPower$ 2 | AddToughness$ 2 | Description$ Enchanted creature gets +2/+2 as long as it's an enchantment. Otherwise, it gets -2/-2. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Enchantment | AddPower$ 2 | AddToughness$ 2 | Description$ Enchanted creature gets +2/+2 as long as it's an enchantment. Otherwise, it gets -2/-2.
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonEnchantment | AddPower$ -2 | AddToughness$ -2 S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonEnchantment | AddPower$ -2 | AddToughness$ -2
SVar:Picture:http://www.wizards.com/global/images/magic/general/nyx_infusion.jpg
Oracle:Enchant creature\nEnchanted creature gets +2/+2 as long as it's an enchantment. Otherwise, it gets -2/-2. Oracle:Enchant creature\nEnchanted creature gets +2/+2 as long as it's an enchantment. Otherwise, it gets -2/-2.

View File

@@ -2,9 +2,7 @@ Name:Phyrexian Boon
ManaCost:2 B ManaCost:2 B
Types:Enchantment Aura Types:Enchantment Aura
K:Enchant creature K:Enchant creature
A:SP$ Attach | Cost$ 2 B | ValidTgts$ Creature | AILogic$ Pump A:SP$ Attach | Cost$ 2 B | ValidTgts$ Creature | AILogic$ SpecificCard | AIValid$ Card.Black
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Black | AddPower$ 2 | AddToughness$ 1 | Description$ Enchanted creature gets +2/+1 as long as it's black. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Black | AddPower$ 2 | AddToughness$ 1 | Description$ Enchanted creature gets +2/+1 as long as it's black.
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonBlack | AddPower$ -1 | AddToughness$ -2 | Description$ Otherwise, it gets -1/-2. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonBlack | AddPower$ -1 | AddToughness$ -2 | Description$ Otherwise, it gets -1/-2.
AI:RemoveDeck:All
SVar:Picture:http://www.wizards.com/global/images/magic/general/phyrexian_boon.jpg
Oracle:Enchant creature\nEnchanted creature gets +2/+1 as long as it's black. Otherwise, it gets -1/-2. Oracle:Enchant creature\nEnchanted creature gets +2/+1 as long as it's black. Otherwise, it gets -1/-2.

View File

@@ -3,9 +3,8 @@ ManaCost:U
Types:Enchantment Aura Types:Enchantment Aura
K:Flash K:Flash
K:Enchant creature K:Enchant creature
A:SP$ Attach | Cost$ U | ValidTgts$ Creature | AILogic$ SpecificCard A:SP$ Attach | Cost$ U | ValidTgts$ Creature | AILogic$ SpecificCard | AIValid$ Pirate
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Pirate | AddToughness$ 2 | Description$ Enchanted creature gets +0/+2 as long as it's a Pirate. Otherwise, it gets -2/-0. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+Pirate | AddToughness$ 2 | Description$ Enchanted creature gets +0/+2 as long as it's a Pirate. Otherwise, it gets -2/-0.
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonPirate | AddPower$ -2 S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonPirate | AddPower$ -2
DeckNeeds:Type$Pirate DeckNeeds:Type$Pirate
SVar:Picture:http://www.wizards.com/global/images/magic/general/sea_legs.jpg
Oracle:Flash\nEnchant creature\nEnchanted creature gets +0/+2 as long as it's a Pirate. Otherwise, it gets -2/-0. Oracle:Flash\nEnchant creature\nEnchanted creature gets +0/+2 as long as it's a Pirate. Otherwise, it gets -2/-0.

View File

@@ -2,9 +2,7 @@ Name:Serra's Boon
ManaCost:2 W ManaCost:2 W
Types:Enchantment Aura Types:Enchantment Aura
K:Enchant creature K:Enchant creature
A:SP$ Attach | Cost$ 2 W | ValidTgts$ Creature | AILogic$ Pump A:SP$ Attach | Cost$ 2 W | ValidTgts$ Creature | AILogic$ SpecificCard | AIValid$ Card.White
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+White | AddPower$ 1 | AddToughness$ 2 | Description$ Enchanted creature gets +1/+2 as long as it's white. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+White | AddPower$ 1 | AddToughness$ 2 | Description$ Enchanted creature gets +1/+2 as long as it's white.
S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonWhite | AddPower$ -2 | AddToughness$ -1 | Description$ Otherwise, it gets -2/-1. S:Mode$ Continuous | Affected$ Creature.EnchantedBy+nonWhite | AddPower$ -2 | AddToughness$ -1 | Description$ Otherwise, it gets -2/-1.
AI:RemoveDeck:All
SVar:Picture:http://www.wizards.com/global/images/magic/general/serras_boon.jpg
Oracle:Enchant creature\nEnchanted creature gets +1/+2 as long as it's white. Otherwise, it gets -2/-1. Oracle:Enchant creature\nEnchanted creature gets +1/+2 as long as it's white. Otherwise, it gets -2/-1.