From 9715021a35b6f9fea5bcce32baba6aa15fb16ada Mon Sep 17 00:00:00 2001 From: Alex Vasile <48962821+Alex-Vasile@users.noreply.github.com> Date: Sun, 17 Jul 2022 19:41:25 -0400 Subject: [PATCH] Fixed GoadAllEffect from affecting creatures that ETB after it resolves. Closes #9227. --- .../src/mage/cards/m/MockingDoppelganger.java | 2 +- .../cards/abilities/keywords/GoadTest.java | 65 +++++++++++++++++++ .../effects/common/combat/GoadAllEffect.java | 5 ++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/m/MockingDoppelganger.java b/Mage.Sets/src/mage/cards/m/MockingDoppelganger.java index 05a192c872..390ae88c33 100644 --- a/Mage.Sets/src/mage/cards/m/MockingDoppelganger.java +++ b/Mage.Sets/src/mage/cards/m/MockingDoppelganger.java @@ -44,7 +44,7 @@ public final class MockingDoppelganger extends CardImpl { @Override public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) { blueprint.getAbilities().add(new SimpleStaticAbility(new GoadAllEffect( - Duration.WhileOnBattlefield, filter + Duration.WhileOnBattlefield, filter, false ).setText("other creatures with the same name as this creature are goaded"))); return true; } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/GoadTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/GoadTest.java index 9abe03a433..ba1927d7ce 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/GoadTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/GoadTest.java @@ -10,6 +10,7 @@ import mage.game.GameException; import mage.game.mulligan.MulliganType; import mage.game.permanent.Permanent; import mage.players.Player; +import mage.util.functions.Function; import org.junit.Assert; import org.junit.Test; import org.mage.test.player.TestPlayer; @@ -62,6 +63,34 @@ public class GoadTest extends CardTestMultiPlayerBase { ); } + /** + * Checks whether the given attacker is NOT goaded by the provided player(s). + * + * @param attacker the name of the attacker + * @param players the player(s) that the attacker is supposed to be goaded by. + */ + private void assertNotGoaded(String attacker, TestPlayer... players) { + Assert.assertTrue("At least one player should be provided", players.length > 0); + Permanent permanent = getPermanent(attacker); + Assert.assertNotEquals( + "Creature should be goaded by " + + Arrays + .stream(players) + .map(Player::getName) + .reduce((a, b) -> a + ", " + b).orElse(""), + permanent.getGoadingPlayers(), + Arrays.stream(players) + .map(TestPlayer::getId) + .collect(Collectors.toSet()) + ); + } + + /** + * Checks whether the given attacker is goaded by the provided player(s). + * + * @param attacker the name of the attacker + * @param players the player(s) that the attacker is supposed to be goaded by. + */ private void assertGoaded(String attacker, TestPlayer... players) { Assert.assertTrue("At least one player should be provided", players.length > 0); Permanent permanent = getPermanent(attacker); @@ -194,4 +223,40 @@ public class GoadTest extends CardTestMultiPlayerBase { assertAttacking("Berserkers of Blood Ridge", playerB, playerC, playerD); } + + /** + * Reported bug: https://github.com/magefree/mage/issues/9227 + * Geode Rager (and other goad all effects) goad creatures that enter the battlefield after the effect resolved. + * + * Ruling: + * Creatures that enter the battlefield or come under the target player’s control after Geode Rager’s ability has resolved won’t be goaded. + * (2020-09-25) + */ + @Test + public void goadAllCorrectAffect() { + addCard(Zone.BATTLEFIELD, playerA, "Geode Rager"); + addCard(Zone.HAND, playerA, "Swamp"); + + addCard(Zone.BATTLEFIELD, playerD, "Goblin Balloon Brigade"); + addCard(Zone.BATTLEFIELD, playerD, "Mountain"); + addCard(Zone.HAND, playerD, "Goblin Champion"); + + setStrictChooseMode(true); + + playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Swamp"); + addTarget(playerA, playerD); // Goad all of playerD's creatures + + castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerD, "Goblin Champion"); + addTarget(playerD, playerC); // Goblin Balloon Brigade attack player C + // Should not have to specify a target for Goblin Champion since they aren't goaded + + setStopAt(2, PhaseStep.DECLARE_BLOCKERS); + + execute(); + assertAllCommandsUsed(); + + assertGoaded("Goblin Balloon Brigade", playerA); + assertNotGoaded("Goblin Champion", playerA); + } + } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/GoadAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/GoadAllEffect.java index 44f6c75a8e..cb01a0a7dd 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/GoadAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/GoadAllEffect.java @@ -24,8 +24,13 @@ public class GoadAllEffect extends ContinuousEffectImpl { } public GoadAllEffect(Duration duration, FilterPermanent filter) { + this(duration, filter, true); + } + + public GoadAllEffect(Duration duration, FilterPermanent filter, boolean affectedObjectsSet) { super(duration, Layer.RulesEffects, SubLayer.NA, Outcome.Detriment); this.filter = filter; + this.affectedObjectsSet = affectedObjectsSet; } private GoadAllEffect(final GoadAllEffect effect) {