Merge pull request #2208 from cg5-/gv-bug

Fix Gratuitous Violence bug
This commit is contained in:
Derek M 2016-08-29 14:25:33 -04:00 committed by GitHub
commit 3ee64af18c
2 changed files with 59 additions and 1 deletions

View file

@ -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

View file

@ -0,0 +1,56 @@
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 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
attack(1, playerA, "Elvish Visionary");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerB, 18);
}
@Test
public void testIgnoresNonCreatures() {
// 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);
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);
}
}