diff --git a/forge-ai/src/main/java/forge/ai/AiProps.java b/forge-ai/src/main/java/forge/ai/AiProps.java index dd43168d764..23b3b791fe6 100644 --- a/forge-ai/src/main/java/forge/ai/AiProps.java +++ b/forge-ai/src/main/java/forge/ai/AiProps.java @@ -70,6 +70,7 @@ public enum AiProps { /** */ ALWAYS_COUNTER_AURAS ("true"), /** */ ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS (""), /** */ CHANCE_TO_COPY_OWN_SPELL_WHILE_ON_STACK ("30"), /** */ + ALWAYS_COPY_SPELL_IF_CMC_DIFF ("2"), /** */ ACTIVELY_DESTROY_ARTS_AND_NONAURA_ENCHS ("true"), /** */ ACTIVELY_DESTROY_IMMEDIATELY_UNBLOCKABLE ("false"), /** */ DESTROY_IMMEDIATELY_UNBLOCKABLE_THRESHOLD ("2"), /** */ diff --git a/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java b/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java index 8cd24cadbf2..68243a9489c 100644 --- a/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java +++ b/forge-ai/src/main/java/forge/ai/ability/CopySpellAbilityAi.java @@ -19,10 +19,24 @@ public class CopySpellAbilityAi extends SpellAbilityAi { @Override protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { Game game = aiPlayer.getGame(); - final int chance = ((PlayerControllerAi)aiPlayer.getController()).getAi().getIntProperty(AiProps.CHANCE_TO_COPY_OWN_SPELL_WHILE_ON_STACK); + int chance = ((PlayerControllerAi)aiPlayer.getController()).getAi().getIntProperty(AiProps.CHANCE_TO_COPY_OWN_SPELL_WHILE_ON_STACK); + int diff = ((PlayerControllerAi)aiPlayer.getController()).getAi().getIntProperty(AiProps.ALWAYS_COPY_SPELL_IF_CMC_DIFF); - if (game.getStack().isEmpty() - || (!MyRandom.percentTrue(chance) && !"AlwaysIfViable".equals(sa.getParam("AILogic"))) + if (game.getStack().isEmpty()) { + return sa.isMandatory(); + } + + final SpellAbility top = game.getStack().peekAbility(); + if (top != null + && top.getPayCosts() != null && top.getPayCosts().getCostMana() != null + && sa.getPayCosts() != null && sa.getPayCosts().getCostMana() != null + && top.getPayCosts().getCostMana().getMana().getCMC() >= sa.getPayCosts().getCostMana().getMana().getCMC() + diff) { + // The copied spell has a significantly higher CMC than the copy spell, consider copying + chance = 100; + } + + if (!MyRandom.percentTrue(chance) + && !"AlwaysIfViable".equals(sa.getParam("AILogic")) && !"OnceIfViable".equals(sa.getParam("AILogic"))) { return false; } @@ -35,7 +49,6 @@ public class CopySpellAbilityAi extends SpellAbilityAi { final TargetRestrictions tgt = sa.getTargetRestrictions(); if (tgt != null) { - final SpellAbility top = game.getStack().peekAbility(); // Filter AI-specific targets if provided if ("OnlyOwned".equals(sa.getParam("AITgts"))) { diff --git a/forge-gui/res/ai/Cautious.ai b/forge-gui/res/ai/Cautious.ai index 5a350cd968c..0e732f97963 100644 --- a/forge-gui/res/ai/Cautious.ai +++ b/forge-gui/res/ai/Cautious.ai @@ -136,6 +136,8 @@ ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS=None # Copy spell on stack logic # The chance that the AI will copy its own stack right after placing it there while it has priority CHANCE_TO_COPY_OWN_SPELL_WHILE_ON_STACK=0 +# If the copied spell costs this much more than the copy spell, the chance to copy the spell will become 100 +ALWAYS_COPY_SPELL_IF_CMC_DIFF=4 # Storm spell logic PRIORITY_REDUCTION_FOR_STORM_SPELLS=9 diff --git a/forge-gui/res/ai/Default.ai b/forge-gui/res/ai/Default.ai index 61dc79aa939..8e03095a670 100644 --- a/forge-gui/res/ai/Default.ai +++ b/forge-gui/res/ai/Default.ai @@ -136,6 +136,8 @@ ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS=None # Copy spell on stack logic # The chance that the AI will copy its own stack right after placing it there while it has priority CHANCE_TO_COPY_OWN_SPELL_WHILE_ON_STACK=30 +# If the copied spell costs this much more than the copy spell, the chance to copy the spell will become 100 +ALWAYS_COPY_SPELL_IF_CMC_DIFF=2 # Storm spell logic PRIORITY_REDUCTION_FOR_STORM_SPELLS=0 diff --git a/forge-gui/res/ai/Experimental.ai b/forge-gui/res/ai/Experimental.ai index ba82a3d6ae3..b5f8624f8a2 100644 --- a/forge-gui/res/ai/Experimental.ai +++ b/forge-gui/res/ai/Experimental.ai @@ -136,6 +136,8 @@ ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS=None # Copy spell on stack logic # The chance that the AI will copy its own stack right after placing it there while it has priority CHANCE_TO_COPY_OWN_SPELL_WHILE_ON_STACK=30 +# If the copied spell costs this much more than the copy spell, the chance to copy the spell will become 100 +ALWAYS_COPY_SPELL_IF_CMC_DIFF=2 # Storm spell logic PRIORITY_REDUCTION_FOR_STORM_SPELLS=9 diff --git a/forge-gui/res/ai/Reckless.ai b/forge-gui/res/ai/Reckless.ai index b5b308473a4..188cf8199a9 100644 --- a/forge-gui/res/ai/Reckless.ai +++ b/forge-gui/res/ai/Reckless.ai @@ -136,6 +136,8 @@ ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS=None # Copy spell on stack logic # The chance that the AI will copy its own stack right after placing it there while it has priority CHANCE_TO_COPY_OWN_SPELL_WHILE_ON_STACK=50 +# If the copied spell costs this much more than the copy spell, the chance to copy the spell will become 100 +ALWAYS_COPY_SPELL_IF_CMC_DIFF=1 # Storm spell logic PRIORITY_REDUCTION_FOR_STORM_SPELLS=0 diff --git a/forge-gui/res/cardsfolder/e/echo_mage.txt b/forge-gui/res/cardsfolder/e/echo_mage.txt index 1cd692a4dcb..755a94da0ba 100644 --- a/forge-gui/res/cardsfolder/e/echo_mage.txt +++ b/forge-gui/res/cardsfolder/e/echo_mage.txt @@ -6,8 +6,8 @@ K:Level up:1 U SVar:maxLevel:4 S:Mode$ Continuous | Affected$ Card.Self | SetPower$ 2 | SetToughness$ 4 | AddAbility$ CopyOnce | CheckSVar$ X | SVarCompare$ EQ1 | Description$ LEVEL 2-3 2/4 CARDNAME gets U U,tap: Copy target instant or sorcery spell. You may choose new targets for the copy. S:Mode$ Continuous | Affected$ Card.Self | SetPower$ 2 | SetToughness$ 5 | AddAbility$ CopyTwice | CheckSVar$ Y | SVarCompare$ EQ1 | Description$ LEVEL 4+ 2/5 CARDNAME gets U U,tap:Copy target instant or sorcery spell twice. You may choose new targets for the copies. -SVar:CopyOnce:AB$CopySpellAbility | Cost$ U U T | ValidTgts$ Instant,Sorcery | SpellDescription$ Copy target instant or sorcery spell. You may choose new targets for the copy. -SVar:CopyTwice:AB$CopySpellAbility | Cost$ U U T | ValidTgts$ Instant,Sorcery | Amount$ 2 | SpellDescription$ Copy target instant or sorcery spell twice. You may choose new targets for the copies. +SVar:CopyOnce:AB$CopySpellAbility | Cost$ U U T | ValidTgts$ Instant,Sorcery | AILogic$ OnceIfViable | SpellDescription$ Copy target instant or sorcery spell. You may choose new targets for the copy. +SVar:CopyTwice:AB$CopySpellAbility | Cost$ U U T | ValidTgts$ Instant,Sorcery | Amount$ 2 | AILogic$ OnceIfViable | SpellDescription$ Copy target instant or sorcery spell twice. You may choose new targets for the copies. SVar:X:Count$Valid Card.Self+counters_GE2_LEVEL+counters_LT4_LEVEL SVar:Y:Count$Valid Card.Self+counters_GE4_LEVEL SVar:Picture:http://www.wizards.com/global/images/magic/general/echo_mage.jpg diff --git a/forge-gui/res/cardsfolder/g/geistblast.txt b/forge-gui/res/cardsfolder/g/geistblast.txt index f9771cd0695..4be13b50adf 100644 --- a/forge-gui/res/cardsfolder/g/geistblast.txt +++ b/forge-gui/res/cardsfolder/g/geistblast.txt @@ -2,6 +2,7 @@ Name:Geistblast ManaCost:2 R Types:Instant A:SP$ DealDamage | Cost$ 2 R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ 2 | SpellDescription$ CARDNAME deals 2 damage to any target. -A:AB$ CopySpellAbility | Cost$ 2 U ExileFromGrave<1/CARDNAME> | ActivationZone$ Graveyard | ValidTgts$ Instant.YouCtrl,Sorcery.YouCtrl | TargetType$ Spell | SpellDescription$ Copy target instant or sorcery spell you control. You may choose new targets for the copy. +A:AB$ CopySpellAbility | Cost$ 2 U ExileFromGrave<1/CARDNAME> | ActivationZone$ Graveyard | ValidTgts$ Instant.YouCtrl,Sorcery.YouCtrl | TargetType$ Spell | SpellDescription$ Copy target instant or sorcery spell you control. You may choose new targets for the copy. +SVar:AIPreference:ExileFromGraveCost$Card.Self SVar:Picture:http://www.wizards.com/global/images/magic/general/geistblast.jpg Oracle:Geistblast deals 2 damage to any target.\n{2}{U}, Exile Geistblast from your graveyard: Copy target instant or sorcery spell you control. You may choose new targets for the copy. diff --git a/forge-gui/res/cardsfolder/l/league_guildmage.txt b/forge-gui/res/cardsfolder/l/league_guildmage.txt index c0cdc4c664c..d8b6669129b 100644 --- a/forge-gui/res/cardsfolder/l/league_guildmage.txt +++ b/forge-gui/res/cardsfolder/l/league_guildmage.txt @@ -3,7 +3,7 @@ ManaCost:U R Types:Creature Human Wizard PT:2/2 A:AB$ Draw | Cost$ 3 U T | NumCards$ 1 | SpellDescription$ Draw a card. -A:AB$ CopySpellAbility | Cost$ X R T | ValidTgts$ Instant.YouCtrl,Sorcery.YouCtrl | TargetType$ Spell | SpellDescription$ Copy target instant or sorcery spell you control with converted mana cost X. You may choose new targets for the copy. +A:AB$ CopySpellAbility | Cost$ X R T | ValidTgts$ Instant.YouCtrl,Sorcery.YouCtrl | TargetType$ Spell | AILogic$ OnceIfViable | SpellDescription$ Copy target instant or sorcery spell you control with converted mana cost X. You may choose new targets for the copy. SVar:X:Targeted$CardManaCost DeckHints:Type$Instant|Sorcery Oracle:{3}{U}, {T}: Draw a card.\n{X}{R}, {T}: Copy target instant or sorcery spell you control with converted mana cost X. You may choose new targets for the copy. diff --git a/forge-gui/res/cardsfolder/m/meletis_charlatan.txt b/forge-gui/res/cardsfolder/m/meletis_charlatan.txt index 02cf1a61ceb..debe3fbbc08 100644 --- a/forge-gui/res/cardsfolder/m/meletis_charlatan.txt +++ b/forge-gui/res/cardsfolder/m/meletis_charlatan.txt @@ -2,6 +2,6 @@ Name:Meletis Charlatan ManaCost:2 U Types:Creature Human Wizard PT:2/3 -A:AB$ CopySpellAbility | Cost$ 2 U T | ValidTgts$ Instant,Sorcery | TargetType$ Spell | Controller$ TargetedController | SpellDescription$ The controller of target instant or sorcery spell copies it. That player may choose new targets for the copy. +A:AB$ CopySpellAbility | Cost$ 2 U T | ValidTgts$ Instant,Sorcery | TargetType$ Spell | Controller$ TargetedController | AILogic$ OnceIfViable | AITgts$ OwnedOnly | SpellDescription$ The controller of target instant or sorcery spell copies it. That player may choose new targets for the copy. SVar:Picture:http://www.wizards.com/global/images/magic/general/meletis_charlatan.jpg Oracle:{2}{U}, {T}: The controller of target instant or sorcery spell copies it. That player may choose new targets for the copy. diff --git a/forge-gui/res/cardsfolder/m/mirror_sheen.txt b/forge-gui/res/cardsfolder/m/mirror_sheen.txt index 4cf65e9c34c..490e40e5ba2 100644 --- a/forge-gui/res/cardsfolder/m/mirror_sheen.txt +++ b/forge-gui/res/cardsfolder/m/mirror_sheen.txt @@ -1,6 +1,6 @@ Name:Mirror Sheen ManaCost:1 UR UR Types:Enchantment -A:AB$ CopySpellAbility | Cost$ 1 UR UR | ValidTgts$ Instant,Sorcery | TargetType$ Spell | TargetValidTargeting$ You | SpellDescription$ Copy target instant or sorcery spell that targets you. You may choose new targets for the copy. +A:AB$ CopySpellAbility | Cost$ 1 UR UR | ValidTgts$ Instant,Sorcery | TargetType$ Spell | TargetValidTargeting$ You | AILogic$ AlwaysIfViable | SpellDescription$ Copy target instant or sorcery spell that targets you. You may choose new targets for the copy. SVar:Picture:http://www.wizards.com/global/images/magic/general/mirror_sheen.jpg Oracle:{1}{U/R}{U/R}: Copy target instant or sorcery spell that targets you. You may choose new targets for the copy. diff --git a/forge-gui/res/cardsfolder/t/tawnos_urzas_apprentice.txt b/forge-gui/res/cardsfolder/t/tawnos_urzas_apprentice.txt index f370baa2447..5aa503852fe 100644 --- a/forge-gui/res/cardsfolder/t/tawnos_urzas_apprentice.txt +++ b/forge-gui/res/cardsfolder/t/tawnos_urzas_apprentice.txt @@ -3,5 +3,5 @@ ManaCost:U R Types:Legendary Creature Human Artificer PT:1/3 K:Haste -A:AB$ CopySpellAbility | Cost$ U R T | TargetType$ Activated.YouCtrl,Triggered.YouCtrl | ValidTgts$ Artifact | SpellDescription$ Copy target activated or triggered ability you control from an artifact source. You may choose new targets for the copy. (Mana abilities can't be targeted.) +A:AB$ CopySpellAbility | Cost$ U R T | TargetType$ Activated.YouCtrl,Triggered.YouCtrl | ValidTgts$ Artifact | AILogic$ OnceIfViable | SpellDescription$ Copy target activated or triggered ability you control from an artifact source. You may choose new targets for the copy. (Mana abilities can't be targeted.) Oracle:Haste\n{U}{R}, {T}: Copy target activated or triggered ability you control from an artifact source. You may choose new targets for the copy. (Mana abilities can't be targeted.)