mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Safe Passage - Fixed a problem that damage to player was not prevented (fixes #6995).
This commit is contained in:
parent
ced6965b59
commit
f1d2d2fb22
3 changed files with 108 additions and 3 deletions
|
@ -22,6 +22,7 @@ public final class SafePassage extends CardImpl {
|
|||
public SafePassage(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}");
|
||||
|
||||
// Prevent all damage that would be dealt to you and creatures you control this turn.
|
||||
this.getSpellAbility().addEffect(new PreventAllDamageToAllEffect(Duration.EndOfTurn, filter));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
|
||||
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 PreventAllDamageTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void test_SafePassage() {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
|
||||
// Prevent all damage that would be dealt to you and creatures you control this turn.
|
||||
addCard(Zone.HAND, playerA, "Safe Passage"); // Instant {2}{W}
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); // (2/2)
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Pillarfield Ox", 2); // (2/4)
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2);
|
||||
|
||||
addCard(Zone.HAND, playerB, "Lightning Bolt",2); // Instnat {R}
|
||||
|
||||
castSpell(2, PhaseStep.UPKEEP, playerA, "Safe Passage");
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", "Silvercoat Lion");
|
||||
|
||||
attack(2, playerB, "Pillarfield Ox");
|
||||
attack(2, playerB, "Pillarfield Ox");
|
||||
|
||||
block(2, playerA, "Silvercoat Lion", "Pillarfield Ox");
|
||||
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Safe Passage", 1);
|
||||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||
|
||||
assertGraveyardCount(playerB, "Lightning Bolt", 2);
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_EtherealHaze() {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
|
||||
// Prevent all damage that would be dealt by creatures this turn.
|
||||
addCard(Zone.HAND, playerA, "Ethereal Haze"); // Instant {W}
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1); // (2/2)
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 2); // (2/4)
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2);
|
||||
|
||||
addCard(Zone.HAND, playerB, "Lightning Bolt",1); // Instant {R}
|
||||
|
||||
castSpell(2, PhaseStep.UPKEEP, playerA, "Ethereal Haze");
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Lightning Bolt", playerA);
|
||||
|
||||
attack(2, playerB, "Silvercoat Lion");
|
||||
attack(2, playerB, "Silvercoat Lion");
|
||||
|
||||
block(2, playerA, "Silvercoat Lion", "Silvercoat Lion");
|
||||
|
||||
setStopAt(2, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertAllCommandsUsed();
|
||||
|
||||
assertGraveyardCount(playerA, "Ethereal Haze", 1);
|
||||
assertPermanentCount(playerA, "Silvercoat Lion", 1);
|
||||
|
||||
assertPermanentCount(playerB, "Silvercoat Lion", 2);
|
||||
assertGraveyardCount(playerB, "Lightning Bolt", 1);
|
||||
|
||||
assertLife(playerA, 17);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
|
@ -13,6 +12,8 @@ import mage.game.Game;
|
|||
import mage.game.events.GameEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageItem;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -34,7 +35,7 @@ public class PreventAllDamageToAllEffect extends PreventionEffectImpl {
|
|||
}
|
||||
|
||||
public PreventAllDamageToAllEffect(Duration duration, FilterPermanentOrPlayer filter, boolean onlyCombat) {
|
||||
super(duration, Integer.MAX_VALUE, onlyCombat);
|
||||
super(duration, Integer.MAX_VALUE, onlyCombat, false);
|
||||
this.filter = filter;
|
||||
staticText = "Prevent all "
|
||||
+ (onlyCombat ? "combat " : "")
|
||||
|
@ -84,7 +85,12 @@ public class PreventAllDamageToAllEffect extends PreventionEffectImpl {
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game)) {
|
||||
MageObject object = game.getObject(event.getTargetId());
|
||||
MageItem object ;
|
||||
if(EventType.DAMAGE_PLAYER.equals(event.getType())) {
|
||||
object = game.getPlayer(event.getTargetId());
|
||||
} else {
|
||||
object = game.getObject(event.getTargetId());
|
||||
}
|
||||
if (object != null) {
|
||||
return filter.match(object, source.getSourceId(), source.getControllerId(), game);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue