mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
[TDM] Implement New Way Forward
This commit is contained in:
parent
937fe8630b
commit
86fe23e396
3 changed files with 114 additions and 25 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
package mage.cards.d;
|
package mage.cards.d;
|
||||||
|
|
||||||
import mage.MageObject;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.PreventionEffectData;
|
import mage.abilities.effects.PreventionEffectData;
|
||||||
import mage.abilities.effects.PreventionEffectImpl;
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
|
|
@ -11,8 +10,6 @@ import mage.constants.Duration;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.game.stack.Spell;
|
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.TargetSource;
|
import mage.target.TargetSource;
|
||||||
|
|
||||||
|
|
@ -44,9 +41,11 @@ class DeflectingPalmEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
private final TargetSource target;
|
private final TargetSource target;
|
||||||
|
|
||||||
public DeflectingPalmEffect() {
|
DeflectingPalmEffect() {
|
||||||
super(Duration.EndOfTurn, Integer.MAX_VALUE, false, false);
|
super(Duration.EndOfTurn, Integer.MAX_VALUE, false, false);
|
||||||
this.staticText = "The next time a source of your choice would deal damage to you this turn, prevent that damage. If damage is prevented this way, {this} deals that much damage to that source's controller";
|
this.staticText = "the next time a source of your choice would deal damage to you this turn, " +
|
||||||
|
"prevent that damage. If damage is prevented this way, " +
|
||||||
|
"{this} deals that much damage to that source's controller";
|
||||||
this.target = new TargetSource();
|
this.target = new TargetSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,31 +70,23 @@ class DeflectingPalmEffect extends PreventionEffectImpl {
|
||||||
PreventionEffectData preventionData = preventDamageAction(event, source, game);
|
PreventionEffectData preventionData = preventDamageAction(event, source, game);
|
||||||
this.used = true;
|
this.used = true;
|
||||||
this.discard(); // only one use
|
this.discard(); // only one use
|
||||||
if (preventionData.getPreventedDamage() > 0) {
|
if (preventionData.getPreventedDamage() < 1) {
|
||||||
MageObject damageDealingObject = game.getObject(target.getFirstTarget());
|
return true;
|
||||||
UUID objectControllerId = null;
|
|
||||||
if (damageDealingObject instanceof Permanent) {
|
|
||||||
objectControllerId = ((Permanent) damageDealingObject).getControllerId();
|
|
||||||
} else if (damageDealingObject instanceof Ability) {
|
|
||||||
objectControllerId = ((Ability) damageDealingObject).getControllerId();
|
|
||||||
} else if (damageDealingObject instanceof Spell) {
|
|
||||||
objectControllerId = ((Spell) damageDealingObject).getControllerId();
|
|
||||||
}
|
}
|
||||||
if (objectControllerId != null) {
|
UUID objectControllerId = game.getControllerId(target.getFirstTarget());
|
||||||
Player objectController = game.getPlayer(objectControllerId);
|
Player objectController = game.getPlayer(objectControllerId);
|
||||||
if (objectController != null) {
|
if (objectController == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
objectController.damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game);
|
objectController.damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (!this.used && super.applies(event, source, game)) {
|
return !this.used
|
||||||
return event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget());
|
&& super.applies(event, source, game)
|
||||||
}
|
&& event.getTargetId().equals(source.getControllerId())
|
||||||
return false;
|
&& event.getSourceId().equals(target.getFirstTarget());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
97
Mage.Sets/src/mage/cards/n/NewWayForward.java
Normal file
97
Mage.Sets/src/mage/cards/n/NewWayForward.java
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
package mage.cards.n;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.delayed.ReflexiveTriggeredAbility;
|
||||||
|
import mage.abilities.effects.PreventionEffectData;
|
||||||
|
import mage.abilities.effects.PreventionEffectImpl;
|
||||||
|
import mage.abilities.effects.common.DamageTargetEffect;
|
||||||
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.target.TargetSource;
|
||||||
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author TheElk801
|
||||||
|
*/
|
||||||
|
public final class NewWayForward extends CardImpl {
|
||||||
|
|
||||||
|
public NewWayForward(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}{R}{W}");
|
||||||
|
|
||||||
|
// The next time a source of your choice would deal damage to you this turn, prevent that damage. When damage is prevented this way, New Way Forward deals that much damage to that source's controller and you draw that many cards.
|
||||||
|
this.getSpellAbility().addEffect(new NewWayForwardEffect());
|
||||||
|
}
|
||||||
|
|
||||||
|
private NewWayForward(final NewWayForward card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NewWayForward copy() {
|
||||||
|
return new NewWayForward(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NewWayForwardEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
|
private final TargetSource target;
|
||||||
|
|
||||||
|
NewWayForwardEffect() {
|
||||||
|
super(Duration.EndOfTurn, Integer.MAX_VALUE, false, false);
|
||||||
|
this.staticText = "the next time a source of your choice would deal damage to you this turn, " +
|
||||||
|
"prevent that damage. When damage is prevented this way, " +
|
||||||
|
"{this} deals that much damage to that source's controller and you draw that many cards";
|
||||||
|
this.target = new TargetSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
private NewWayForwardEffect(final NewWayForwardEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.target = effect.target.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NewWayForwardEffect copy() {
|
||||||
|
return new NewWayForwardEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(Ability source, Game game) {
|
||||||
|
super.init(source, game);
|
||||||
|
this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
|
PreventionEffectData preventionData = preventDamageAction(event, source, game);
|
||||||
|
this.used = true;
|
||||||
|
this.discard(); // only one use
|
||||||
|
if (preventionData.getPreventedDamage() < 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
UUID objectControllerId = game.getControllerId(target.getFirstTarget());
|
||||||
|
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(
|
||||||
|
new DamageTargetEffect(preventionData.getPreventedDamage())
|
||||||
|
.setTargetPointer(new FixedTarget(objectControllerId)),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
ability.addEffect(new DrawCardSourceControllerEffect(preventionData.getPreventedDamage()));
|
||||||
|
game.fireReflexiveTriggeredAbility(ability, source);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
|
return !this.used
|
||||||
|
&& super.applies(event, source, game)
|
||||||
|
&& event.getTargetId().equals(source.getControllerId())
|
||||||
|
&& event.getSourceId().equals(target.getFirstTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -176,6 +176,7 @@ public final class TarkirDragonstorm extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Narset, Jeskai Waymaster", 209, Rarity.RARE, mage.cards.n.NarsetJeskaiWaymaster.class));
|
cards.add(new SetCardInfo("Narset, Jeskai Waymaster", 209, Rarity.RARE, mage.cards.n.NarsetJeskaiWaymaster.class));
|
||||||
cards.add(new SetCardInfo("Nature's Rhythm", 150, Rarity.RARE, mage.cards.n.NaturesRhythm.class));
|
cards.add(new SetCardInfo("Nature's Rhythm", 150, Rarity.RARE, mage.cards.n.NaturesRhythm.class));
|
||||||
cards.add(new SetCardInfo("Neriv, Heart of the Storm", 210, Rarity.MYTHIC, mage.cards.n.NerivHeartOfTheStorm.class));
|
cards.add(new SetCardInfo("Neriv, Heart of the Storm", 210, Rarity.MYTHIC, mage.cards.n.NerivHeartOfTheStorm.class));
|
||||||
|
cards.add(new SetCardInfo("New Way Forward", 211, Rarity.RARE, mage.cards.n.NewWayForward.class));
|
||||||
cards.add(new SetCardInfo("Nightblade Brigade", 85, Rarity.COMMON, mage.cards.n.NightbladeBrigade.class));
|
cards.add(new SetCardInfo("Nightblade Brigade", 85, Rarity.COMMON, mage.cards.n.NightbladeBrigade.class));
|
||||||
cards.add(new SetCardInfo("Nomad Outpost", 263, Rarity.UNCOMMON, mage.cards.n.NomadOutpost.class));
|
cards.add(new SetCardInfo("Nomad Outpost", 263, Rarity.UNCOMMON, mage.cards.n.NomadOutpost.class));
|
||||||
cards.add(new SetCardInfo("Opulent Palace", 264, Rarity.UNCOMMON, mage.cards.o.OpulentPalace.class));
|
cards.add(new SetCardInfo("Opulent Palace", 264, Rarity.UNCOMMON, mage.cards.o.OpulentPalace.class));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue