* Prevention effects - Fixed that prevention effects also prevented damage that was not preventable (fixes #983).

This commit is contained in:
LevelX2 2015-05-21 00:25:37 +02:00
parent f5245ade01
commit 6097e297fe
3 changed files with 77 additions and 1 deletions

View file

@ -33,6 +33,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.CantBeCounteredSourceEffect;
import mage.abilities.effects.common.DamageTargetEffect;
@ -60,9 +61,14 @@ public class Combust extends CardImpl {
super(ownerId, 130, "Combust", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{R}");
this.expansionSetCode = "M11";
// Combust deals 5 damage to target white or blue creature. The damage can't be prevented.
this.getSpellAbility().addEffect(new DamageTargetEffect(5, false));
this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter));
this.addAbility(new SimpleStaticAbility(Zone.STACK, new CantBeCounteredSourceEffect()));
// Combust can't be countered by spells or abilities.
Ability ability = new SimpleStaticAbility(Zone.STACK, new CantBeCounteredSourceEffect());
ability.setRuleAtTheTop(true);
this.addAbility(ability);
}
public Combust(final Combust card) {

View file

@ -0,0 +1,67 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.prevention;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class SwansOfBrynArgollTest extends CardTestPlayerBase{
/**
* Since you can't prevent damage that Combust deals, it should be able to kill Swans of Bryn Argoll.
*/
@Test
public void testMarkOfAsylumEffect() {
// 4/3 Flying
// If a source would deal damage to Swans of Bryn Argoll, prevent that damage. The source's controller draws cards equal to the damage prevented this way.
addCard(Zone.BATTLEFIELD, playerA, "Swans of Bryn Argoll");
// Combust deals 5 damage to target white or blue creature. The damage can't be prevented.
// Combust can't be countered by spells or abilities.
addCard(Zone.HAND, playerB, "Combust", 1);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Combust", "Swans of Bryn Argoll");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, "Combust", 1);
assertPermanentCount(playerA, "Swans of Bryn Argoll", 0);
assertGraveyardCount(playerA, "Swans of Bryn Argoll", 1);
assertHandCount(playerA, 0);
}
}

View file

@ -2112,6 +2112,9 @@ public abstract class GameImpl implements Game, Serializable {
@Override
public PreventionEffectData preventDamage(GameEvent event, Ability source, Game game, int amountToPrevent) {
PreventionEffectData result = new PreventionEffectData(amountToPrevent);
if (!event.getFlag()) { // damage is not preventable
return result;
}
if (!(event instanceof DamageEvent)) {
result.setError(true);
return result;