From 2439b9903159f8c2909bf806360f22bef4f9c1e5 Mon Sep 17 00:00:00 2001 From: cg5 Date: Mon, 29 Aug 2016 19:51:26 +0200 Subject: [PATCH 1/2] Add tests for Gratuitous Violence - confirmed bug --- .../cards/single/GratuitousViolenceTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/GratuitousViolenceTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/GratuitousViolenceTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/GratuitousViolenceTest.java new file mode 100644 index 0000000000..1301232e24 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/GratuitousViolenceTest.java @@ -0,0 +1,52 @@ +package org.mage.test.cards.single; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author cg5 + */ +public class GratuitousViolenceTest extends CardTestPlayerBase { + @Test + public void testWorksOnCreatures() { + addCard(Zone.BATTLEFIELD, playerA, "Gratuitous Violence"); + addCard(Zone.BATTLEFIELD, playerA, "Elvish Visionary"); // 1/1 + + attack(1, playerA, "Elvish Visionary"); + + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + execute(); + assertLife(playerB, 18); + } + + @Test + public void testIgnoresNonCreatures() { + addCard(Zone.BATTLEFIELD, playerA, "Gratuitous Violence"); + addCard(Zone.BATTLEFIELD, playerA, "Honden of Infinite Rage"); + + addTarget(playerA, playerB); + + setStopAt(1, PhaseStep.PRECOMBAT_MAIN); + execute(); + + // Honden should deal 1 damage at upkeep (since playerA only + // has one Shrine). GV should not double this. + assertLife(playerB, 19); + } + + @Test + public void testIgnoresInstants() { + addCard(Zone.BATTLEFIELD, playerA, "Gratuitous Violence"); + addCard(Zone.BATTLEFIELD, playerA, "Mountain"); + addCard(Zone.HAND, playerA, "Lightning Bolt"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + + setStopAt(1, PhaseStep.POSTCOMBAT_MAIN); + execute(); + assertLife(playerB, 17); + } +} From 8cbffb3e69b78e9f6b88790715e0c43f8da56a59 Mon Sep 17 00:00:00 2001 From: cg5 Date: Mon, 29 Aug 2016 20:10:01 +0200 Subject: [PATCH 2/2] Fix Gratuitous Violence bug --- Mage.Sets/src/mage/sets/onslaught/GratuitousViolence.java | 4 +++- .../mage/test/cards/single/GratuitousViolenceTest.java | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Mage.Sets/src/mage/sets/onslaught/GratuitousViolence.java b/Mage.Sets/src/mage/sets/onslaught/GratuitousViolence.java index 7bd1e97fb8..908e5c001f 100644 --- a/Mage.Sets/src/mage/sets/onslaught/GratuitousViolence.java +++ b/Mage.Sets/src/mage/sets/onslaught/GratuitousViolence.java @@ -95,7 +95,9 @@ class GratuitousViolenceReplacementEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); - return permanent != null && permanent.getControllerId().equals(source.getControllerId()); + return permanent != null + && permanent.getCardType().contains(CardType.CREATURE) + && permanent.getControllerId().equals(source.getControllerId()); } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/GratuitousViolenceTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/GratuitousViolenceTest.java index 1301232e24..e6f75563c8 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/GratuitousViolenceTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/GratuitousViolenceTest.java @@ -11,7 +11,9 @@ import org.mage.test.serverside.base.CardTestPlayerBase; */ public class GratuitousViolenceTest extends CardTestPlayerBase { @Test - public void testWorksOnCreatures() { + public void testDoublesDamageFromCreatures() { + // Enchantment: If a creature you control would deal damage to a creature + // or player, it deals double that damage to that creature or player instead. addCard(Zone.BATTLEFIELD, playerA, "Gratuitous Violence"); addCard(Zone.BATTLEFIELD, playerA, "Elvish Visionary"); // 1/1 @@ -24,8 +26,10 @@ public class GratuitousViolenceTest extends CardTestPlayerBase { @Test public void testIgnoresNonCreatures() { - addCard(Zone.BATTLEFIELD, playerA, "Gratuitous Violence"); + // Legendary Enchantment - Shrine: At the beginning of your upkeep, Honden of Infinite + // Rage deals damage to target creature or player equal to the number of Shrines you control. addCard(Zone.BATTLEFIELD, playerA, "Honden of Infinite Rage"); + addCard(Zone.BATTLEFIELD, playerA, "Gratuitous Violence"); addTarget(playerA, playerB);