mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
fix damage prevention to multiple targets
This commit is contained in:
parent
3abce2f5c8
commit
b4dbc75ac5
2 changed files with 51 additions and 2 deletions
|
|
@ -0,0 +1,48 @@
|
|||
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 xenohedron
|
||||
*/
|
||||
public class PreventDamageToTargetTest extends CardTestPlayerBase {
|
||||
|
||||
private static final String redeem = "Redeem"; // 1W Instant
|
||||
// Prevent all damage that would be dealt this turn to up to two target creatures.
|
||||
|
||||
private static final String pyroclasm = "Pyroclasm"; // 1R Sorcery
|
||||
// Pyroclasm deals 2 damage to each creature.
|
||||
|
||||
private static final String hatchling = "Kraken Hatchling"; // 0/4
|
||||
private static final String turtle = "Aegis Turtle"; // 0/5
|
||||
private static final String crab = "Fortress Crab"; // 1/6
|
||||
private static final String golem = "Hexplate Golem"; // 5/7
|
||||
|
||||
@Test
|
||||
public void testDamagePreventedBothTargets() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Plains", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, hatchling);
|
||||
addCard(Zone.BATTLEFIELD, playerA, turtle);
|
||||
addCard(Zone.BATTLEFIELD, playerB, crab);
|
||||
addCard(Zone.BATTLEFIELD, playerB, golem);
|
||||
addCard(Zone.HAND, playerA, pyroclasm);
|
||||
addCard(Zone.HAND, playerB, redeem);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, pyroclasm);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, redeem, turtle + "^" + crab);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertDamageReceived(playerA, hatchling, 2);
|
||||
assertDamageReceived(playerA, turtle, 0);
|
||||
assertDamageReceived(playerB, crab, 0);
|
||||
assertDamageReceived(playerB, golem, 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.constants.Duration;
|
||||
|
|
@ -45,7 +44,9 @@ public class PreventDamageToTargetEffect extends PreventionEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return !this.used && super.applies(event, source, game) && event.getTargetId().equals(getTargetPointer().getFirst(game, source));
|
||||
return !this.used
|
||||
&& super.applies(event, source, game)
|
||||
&& getTargetPointer().getTargets(game, source).contains(event.getTargetId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue