From 4da4a333d97cf67cce9c2b2c92ec885a414d0a5a Mon Sep 17 00:00:00 2001 From: tool4ever Date: Fri, 7 Apr 2023 12:23:17 +0200 Subject: [PATCH] Fix AI cheating with Avacyn's Judgement (#2853) --- .../src/main/java/forge/game/ability/AbilityUtils.java | 9 +++++---- .../main/java/forge/game/ability/effects/PlayEffect.java | 1 + forge-gui/res/cardsfolder/d/dark_apostle.txt | 2 +- forge-gui/res/cardsfolder/d/deep_gnome_terramancer.txt | 2 +- forge-gui/res/cardsfolder/f/followed_footsteps.txt | 2 +- .../cardsfolder/m/mirrorhall_mimic_ghastly_mimicry.txt | 2 +- forge-gui/res/cardsfolder/s/sloppity_bilepiper.txt | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index e5c27f2041e..30047654ae3 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -1783,6 +1783,11 @@ public class AbilityUtils { return doXMath(Integer.parseInt(kicked ? sq[1] : sq[2]), expr, c, ctb); } + // Count$Madness.. + if (sq[0].startsWith("Madness")) { + return doXMath(calculateAmount(c, sq[sa.isMadness() ? 1 : 2], ctb), expr, c, ctb); + } + //Count$HasNumChosenColors. if (sq[0].contains("HasNumChosenColors")) { int sum = 0; @@ -2006,10 +2011,6 @@ public class AbilityUtils { final boolean isMulti = c.getColor().isMulticolor(); return doXMath(Integer.parseInt(sq[isMulti ? 1 : 2]), expr, c, ctb); } - // Count$Madness.. - if (sq[0].startsWith("Madness")) { - return doXMath(calculateAmount(c, sq[c.isMadness() ? 1 : 2], ctb), expr, c, ctb); - } // Count$Foretold.. if (sq[0].startsWith("Foretold")) { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index 2b6006e10ed..d2b8d03f7a3 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -314,6 +314,7 @@ public class PlayEffect extends SpellAbilityEffect { // only one mode can be used tgtSA = sa.getActivatingPlayer().getController().getAbilityToPlay(tgtCard, sas); } + // in case player canceled from choice dialog if (tgtSA == null) { if (wasFaceDown) { diff --git a/forge-gui/res/cardsfolder/d/dark_apostle.txt b/forge-gui/res/cardsfolder/d/dark_apostle.txt index 8556399ca79..f5c133c6c1b 100644 --- a/forge-gui/res/cardsfolder/d/dark_apostle.txt +++ b/forge-gui/res/cardsfolder/d/dark_apostle.txt @@ -4,7 +4,7 @@ Types:Creature Astartes Warlock PT:3/3 A:AB$ Effect | PrecostDesc$ Gift of Chaos — | Cost$ 3 T | StaticAbilities$ GrantCascade | Triggers$ ExileEffect | SpellDescription$ The next noncreature spell you cast this turn has cascade. (When you cast that spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom of your library in a random order.) SVar:GrantCascade:Mode$ Continuous | EffectZone$ Command | Affected$ Card.nonCreature+YouCtrl | AffectedZone$ Stack | AddKeyword$ Cascade | Description$ The next noncreature spell you cast this turn has cascade. -SVar:ExileEffect:Mode$ SpellCast | EffectZone$ Command | Valid$ Card.nonCreature+YouCtrl | AffectedZone$ Stack | Execute$ RemoveEffect | Static$ True +SVar:ExileEffect:Mode$ SpellCast | EffectZone$ Command | ValidCard$ Card.nonCreature+YouCtrl | AffectedZone$ Stack | Execute$ RemoveEffect | Static$ True SVar:RemoveEffect:DB$ ChangeZone | Origin$ Command | Destination$ Exile | Defined$ Self DeckHas:Keyword$Cascade Oracle:Gift of Chaos — {3}, {T}: The next noncreature spell you cast this turn has cascade. (When you cast that spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom of your library in a random order.) diff --git a/forge-gui/res/cardsfolder/d/deep_gnome_terramancer.txt b/forge-gui/res/cardsfolder/d/deep_gnome_terramancer.txt index e013dd8dbd7..9f03d4c538b 100644 --- a/forge-gui/res/cardsfolder/d/deep_gnome_terramancer.txt +++ b/forge-gui/res/cardsfolder/d/deep_gnome_terramancer.txt @@ -3,7 +3,7 @@ ManaCost:1 W Types:Creature Gnome Wizard PT:2/2 K:Flash -T:Mode$ ChangesZoneAll | ValidCards$ Land.OppCtrl | ValidCause$ !LandAbility | Destination$ Battlefield | TriggerZones$ Battlefield | ActivationLimit$ 1 | Execute$ TrigSearch | OptionalDecider$ You | TriggerDescription$ Mold Earth — Whenever one or more lands enter the battlefield under an opponent's control without being played, you may search your library for a Plains card, put it onto the battlefield tapped, then shuffle. Do this only once each turn. +T:Mode$ ChangesZoneAll | ValidCards$ Land.OppCtrl | ValidCause$ !LandAbility | Destination$ Battlefield | TriggerZones$ Battlefield | ResolvedLimit$ 1 | Execute$ TrigSearch | OptionalDecider$ You | TriggerDescription$ Mold Earth — Whenever one or more lands enter the battlefield under an opponent's control without being played, you may search your library for a Plains card, put it onto the battlefield tapped, then shuffle. Do this only once each turn. SVar:TrigSearch:DB$ ChangeZone | Origin$ Library | Destination$ Battlefield | Tapped$ True | ChangeType$ Card.Plains | ChangeNum$ 1 | ShuffleNonMandatory$ True AI:RemoveDeck:Random Oracle:Flash\nMold Earth — Whenever one or more lands enter the battlefield under an opponent's control without being played, you may search your library for a Plains card, put it onto the battlefield tapped, then shuffle. Do this only once each turn. diff --git a/forge-gui/res/cardsfolder/f/followed_footsteps.txt b/forge-gui/res/cardsfolder/f/followed_footsteps.txt index ce02d3e03a9..fdaea176075 100644 --- a/forge-gui/res/cardsfolder/f/followed_footsteps.txt +++ b/forge-gui/res/cardsfolder/f/followed_footsteps.txt @@ -4,5 +4,5 @@ Types:Enchantment Aura K:Enchant creature A:SP$ Attach | ValidTgts$ Creature | AILogic$ HighestEvaluation T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ TrigCopy | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of your upkeep, create a token that's a copy of enchanted creature. -SVar:TrigCopy:DB$ CopyPermanent | Defined$ Enchanted | SpellDescription$ At the beginning of your upkeep, create a token that's a copy of enchanted creature. +SVar:TrigCopy:DB$ CopyPermanent | Defined$ Enchanted Oracle:Enchant creature\nAt the beginning of your upkeep, create a token that's a copy of enchanted creature. diff --git a/forge-gui/res/cardsfolder/m/mirrorhall_mimic_ghastly_mimicry.txt b/forge-gui/res/cardsfolder/m/mirrorhall_mimic_ghastly_mimicry.txt index 7b8fdcde79e..236cd106b80 100644 --- a/forge-gui/res/cardsfolder/m/mirrorhall_mimic_ghastly_mimicry.txt +++ b/forge-gui/res/cardsfolder/m/mirrorhall_mimic_ghastly_mimicry.txt @@ -18,7 +18,7 @@ Types:Enchantment Aura K:Enchant creature A:SP$ Attach | ValidTgts$ Creature | TgtPrompt$ Select target creature | AILogic$ HighestEvaluation T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ TrigCopy | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of your upkeep, create a token that's a copy of enchanted creature, except it's a Spirit in addition to its other types. -SVar:TrigCopy:DB$ CopyPermanent | Defined$ Enchanted | AddTypes$ Spirit | SpellDescription$ At the beginning of your upkeep, create a token that's a copy of enchanted creature, except it's a Spirit in addition to its other types. +SVar:TrigCopy:DB$ CopyPermanent | Defined$ Enchanted | AddTypes$ Spirit R:Event$ Moved | ValidCard$ Card.Self | Destination$ Graveyard | ReplaceWith$ Exile | Description$ If CARDNAME would be put into a graveyard from anywhere, exile it instead. SVar:Exile:DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Exile | Defined$ ReplacedCard Oracle:Enchant creature\nAt the beginning of your upkeep, create a token that's a copy of enchanted creature, except it's a Spirit in addition to its other types.\nIf Ghastly Mimicry would be put into a graveyard from anywhere, exile it instead. diff --git a/forge-gui/res/cardsfolder/s/sloppity_bilepiper.txt b/forge-gui/res/cardsfolder/s/sloppity_bilepiper.txt index ba5b6fb4583..49590bf287b 100644 --- a/forge-gui/res/cardsfolder/s/sloppity_bilepiper.txt +++ b/forge-gui/res/cardsfolder/s/sloppity_bilepiper.txt @@ -4,7 +4,7 @@ Types:Creature Demon PT:3/3 A:AB$ Effect | PrecostDesc$ Jolly Gutpipes — | Cost$ 2 T Sac<1/Creature> | StaticAbilities$ GrantCascade | Triggers$ ExileEffect | SpellDescription$ The next creature spell you cast this turn has cascade. (When you cast your next creature spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom of your library in a random order.) SVar:GrantCascade:Mode$ Continuous | EffectZone$ Command | Affected$ Card.Creature+YouCtrl | AffectedZone$ Stack | Execute$ ExileEff | AddKeyword$ Cascade | Description$ The next noncreature spell you cast this turn has cascade. -SVar:ExileEffect:Mode$ SpellCast | EffectZone$ Command | Valid$ Card.Creature+YouCtrl | AffectedZone$ Stack | Execute$ RemoveEffect | Static$ True +SVar:ExileEffect:Mode$ SpellCast | EffectZone$ Command | ValidCard$ Card.Creature+YouCtrl | AffectedZone$ Stack | Execute$ RemoveEffect | Static$ True SVar:RemoveEffect:DB$ ChangeZone | Origin$ Command | Destination$ Exile | Defined$ Self DeckHas:Keyword$Cascade & Ability$Sacrifice Oracle:Jolly Gutpipes — {2}, {T}, Sacrifice a creature: The next creature spell you cast this turn has cascade. (When you cast your next creature spell, exile cards from the top of your library until you exile a nonland card that costs less. You may cast it without paying its mana cost. Put the exiled cards on the bottom of your library in a random order.)