forked from External/mage
implement [MIR] Reflect Damage
This commit is contained in:
parent
94e58b6f77
commit
61bfdb2e39
2 changed files with 88 additions and 0 deletions
87
Mage.Sets/src/mage/cards/r/ReflectDamage.java
Normal file
87
Mage.Sets/src/mage/cards/r/ReflectDamage.java
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
package mage.cards.r;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.RedirectionEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Controllable;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.TargetSource;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author xenohedron
|
||||
*/
|
||||
public final class ReflectDamage extends CardImpl {
|
||||
|
||||
public ReflectDamage(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{R}{W}");
|
||||
|
||||
// The next time a source of your choice would deal damage this turn, that damage is dealt to that source's controller instead.
|
||||
this.getSpellAbility().addEffect(new ReflectDamageEffect());
|
||||
}
|
||||
|
||||
private ReflectDamage(final ReflectDamage card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReflectDamage copy() {
|
||||
return new ReflectDamage(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ReflectDamageEffect extends RedirectionEffect {
|
||||
|
||||
private final TargetSource damageSource;
|
||||
|
||||
ReflectDamageEffect() {
|
||||
super(Duration.EndOfTurn, Integer.MAX_VALUE, UsageType.ONE_USAGE_ABSOLUTE);
|
||||
staticText = "The next time a source of your choice would deal damage this turn, that damage is dealt to that source's controller instead";
|
||||
this.damageSource = new TargetSource();
|
||||
}
|
||||
|
||||
private ReflectDamageEffect(final ReflectDamageEffect effect) {
|
||||
super(effect);
|
||||
this.damageSource = effect.damageSource.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReflectDamageEffect copy() {
|
||||
return new ReflectDamageEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
this.damageSource.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
// check source, can be spell or other stack object, must find controller
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (object instanceof Spell && ((Spell) object).getSourceId().equals(damageSource.getFirstTarget())) {
|
||||
TargetPlayer target = new TargetPlayer();
|
||||
target.add(((Spell) object).getControllerId(), game);
|
||||
this.redirectTarget = target;
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Controllable && object.getId().equals(damageSource.getFirstTarget())) {
|
||||
TargetPlayer target = new TargetPlayer();
|
||||
target.add(((Controllable) object).getControllerId(), game);
|
||||
this.redirectTarget = target;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -263,6 +263,7 @@ public final class Mirage extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Reality Ripple", "87+", Rarity.COMMON, mage.cards.r.RealityRipple.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Reality Ripple", 87, Rarity.COMMON, mage.cards.r.RealityRipple.class, NON_FULL_USE_VARIOUS));
|
||||
cards.add(new SetCardInfo("Reckless Embermage", 189, Rarity.RARE, mage.cards.r.RecklessEmbermage.class));
|
||||
cards.add(new SetCardInfo("Reflect Damage", 277, Rarity.RARE, mage.cards.r.ReflectDamage.class));
|
||||
cards.add(new SetCardInfo("Regeneration", 236, Rarity.COMMON, mage.cards.r.Regeneration.class));
|
||||
cards.add(new SetCardInfo("Reign of Chaos", 190, Rarity.UNCOMMON, mage.cards.r.ReignOfChaos.class));
|
||||
cards.add(new SetCardInfo("Reign of Terror", 137, Rarity.UNCOMMON, mage.cards.r.ReignOfTerror.class));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue