forked from External/mage
* Martyrs of Korlis - fixed that redirect damage effect doesn't work;
This commit is contained in:
parent
60eb9ff5ce
commit
a3fee30ed6
2 changed files with 60 additions and 10 deletions
|
|
@ -1,40 +1,44 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.InvertCondition;
|
||||
import mage.abilities.condition.common.SourceTappedCondition;
|
||||
import mage.abilities.decorator.ConditionalContinuousEffect;
|
||||
import mage.abilities.decorator.ConditionalReplacementEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.RedirectionEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author MarcoMarin
|
||||
*/
|
||||
public final class MartyrsOfKorlis extends CardImpl {
|
||||
|
||||
public MartyrsOfKorlis(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}");
|
||||
this.subtype.add(SubType.HUMAN);
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(6);
|
||||
|
||||
// As long as Martyrs of Korlis is untapped, all damage that would be dealt to you by artifacts is dealt to Martyrs of Korlis instead.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(
|
||||
Effect effect = new ConditionalReplacementEffect(
|
||||
new RedirectArtifactDamageFromPlayerToSourceEffect(Duration.WhileOnBattlefield),
|
||||
new InvertCondition(SourceTappedCondition.instance),
|
||||
"{this} redirects artifact damage from controller as long as it's untapped")));
|
||||
null);
|
||||
effect.setText("{this} redirects artifact damage from controller as long as it's untapped");
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
||||
}
|
||||
|
||||
public MartyrsOfKorlis(final MartyrsOfKorlis card) {
|
||||
|
|
@ -50,7 +54,7 @@ public final class MartyrsOfKorlis extends CardImpl {
|
|||
class RedirectArtifactDamageFromPlayerToSourceEffect extends RedirectionEffect {
|
||||
|
||||
public RedirectArtifactDamageFromPlayerToSourceEffect(Duration duration) {
|
||||
super(duration);
|
||||
super(duration);
|
||||
}
|
||||
|
||||
public RedirectArtifactDamageFromPlayerToSourceEffect(final RedirectArtifactDamageFromPlayerToSourceEffect effect) {
|
||||
|
|
@ -64,9 +68,13 @@ class RedirectArtifactDamageFromPlayerToSourceEffect extends RedirectionEffect {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getTargetId().equals(source.getControllerId())&&
|
||||
if (event.getTargetId().equals(source.getControllerId()) &&
|
||||
game.getPermanentOrLKIBattlefield(event.getSourceId()).isArtifact()) {
|
||||
this.redirectTarget.updateTarget(source.getSourceId(), game);
|
||||
|
||||
TargetPermanent target = new TargetPermanent();
|
||||
target.add(source.getSourceId(), game);
|
||||
this.redirectTarget = target;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package org.mage.test.cards.continuous;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class MartyrsOfKorlisTest extends CardTestPlayerBase {
|
||||
|
||||
// Martyrs of Korlis 1/6
|
||||
// As long as Martyrs of Korlis is untapped, all damage that would be dealt to you by artifacts is dealt to Martyrs of Korlis instead.
|
||||
|
||||
@Test
|
||||
public void test_PreventDamageToGideonOnYourTurn() {
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Martyrs of Korlis");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Alloy Myr"); // 2/2
|
||||
|
||||
// with redirect
|
||||
checkDamage("turn 1 before", 1, PhaseStep.PRECOMBAT_MAIN, playerB, "Martyrs of Korlis", 0);
|
||||
checkLife("turn 1 before", 1, PhaseStep.PRECOMBAT_MAIN, playerB, 20);
|
||||
attack(1, playerA, "Alloy Myr", playerB);
|
||||
checkDamage("turn 1 after", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Martyrs of Korlis", 2);
|
||||
checkLife("turn 1 after", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, 20);
|
||||
|
||||
attack(2, playerB, "Martyrs of Korlis", playerA);
|
||||
|
||||
// without redirect
|
||||
checkDamage("turn 3 before", 3, PhaseStep.PRECOMBAT_MAIN, playerB, "Martyrs of Korlis", 0);
|
||||
checkLife("turn 3 before", 3, PhaseStep.PRECOMBAT_MAIN, playerB, 20);
|
||||
attack(3, playerA, "Alloy Myr", playerB);
|
||||
checkDamage("turn 3 after", 3, PhaseStep.POSTCOMBAT_MAIN, playerB, "Martyrs of Korlis", 0);
|
||||
checkLife("turn 3 after", 3, PhaseStep.POSTCOMBAT_MAIN, playerB, 20 - 2);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(3, PhaseStep.END_TURN);
|
||||
execute();
|
||||
assertAllCommandsUsed();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue