From a0d2c0c22f0743a2fbd6268379eeefe238702120 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 13 Jan 2015 14:42:20 +0100 Subject: [PATCH] * Sulforic Vortex and Flames of the Blood Hand - Fixed that the life gain preventing effects were not implemented as replacement effects. --- .../mage/sets/alliances/SustainingSpirit.java | 32 ++++++------ .../FlamesOfTheBloodHand.java | 47 +++++++++++++++-- .../src/mage/sets/scourge/SulfuricVortex.java | 52 +++++++++++++++++-- .../costs/common/GainLifeOpponentCost.java | 2 +- 4 files changed, 109 insertions(+), 24 deletions(-) diff --git a/Mage.Sets/src/mage/sets/alliances/SustainingSpirit.java b/Mage.Sets/src/mage/sets/alliances/SustainingSpirit.java index 885630993e..9c717453a4 100644 --- a/Mage.Sets/src/mage/sets/alliances/SustainingSpirit.java +++ b/Mage.Sets/src/mage/sets/alliances/SustainingSpirit.java @@ -90,25 +90,27 @@ class SustainingSpiritReplacementEffect extends ReplacementEffectImpl { return new SustainingSpiritReplacementEffect(this); } + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType().equals(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS)) { - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null - && (controller.getLife() > 0) &&(controller.getLife() - event.getAmount()) < 1 - && event.getPlayerId().equals(controller.getId()) - ) { - event.setAmount(controller.getLife() - 1); - //unsure how to make this comply with - // 10/1/2008: The ability doesn't change how much damage is dealt; - // it just changes how much life that damage makes you lose. - // An effect such as Spirit Link will see the full amount of damage being dealt. - } + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null + && (controller.getLife() > 0) &&(controller.getLife() - event.getAmount()) < 1 + && event.getPlayerId().equals(controller.getId()) + ) { + event.setAmount(controller.getLife() - 1); + //unsure how to make this comply with + // 10/1/2008: The ability doesn't change how much damage is dealt; + // it just changes how much life that damage makes you lose. + // An effect such as Spirit Link will see the full amount of damage being dealt. } } - return false; } diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/FlamesOfTheBloodHand.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/FlamesOfTheBloodHand.java index 04e3903cb1..7f1e0b2ec2 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/FlamesOfTheBloodHand.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/FlamesOfTheBloodHand.java @@ -28,13 +28,18 @@ package mage.sets.betrayersofkamigawa; import java.util.UUID; +import mage.abilities.Ability; import mage.abilities.effects.Effect; +import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.continious.CantGainLifeTargetEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Outcome; import mage.constants.Rarity; +import mage.game.Game; +import mage.game.events.GameEvent; import mage.target.TargetPlayer; /** @@ -52,9 +57,7 @@ public class FlamesOfTheBloodHand extends CardImpl { // Flames of the Blood Hand deals 4 damage to target player. The damage can't be prevented. this.getSpellAbility().addEffect(new DamageTargetEffect(4, false)); // If that player would gain life this turn, that player gains no life instead. - Effect effect = new CantGainLifeTargetEffect(Duration.EndOfTurn); - effect.setText("If that player would gain life this turn, that player gains no life instead"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new FlamesOfTheBloodHandReplacementEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); } @@ -67,3 +70,41 @@ public class FlamesOfTheBloodHand extends CardImpl { return new FlamesOfTheBloodHand(this); } } + +class FlamesOfTheBloodHandReplacementEffect extends ReplacementEffectImpl { + + public FlamesOfTheBloodHandReplacementEffect() { + super(Duration.EndOfTurn, Outcome.Benefit); + staticText = "If that player would gain life this turn, that player gains no life instead"; + } + + public FlamesOfTheBloodHandReplacementEffect(final FlamesOfTheBloodHandReplacementEffect effect) { + super(effect); + } + + @Override + public FlamesOfTheBloodHandReplacementEffect copy() { + return new FlamesOfTheBloodHandReplacementEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.GAIN_LIFE; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return event.getPlayerId().equals(getTargetPointer().getFirst(game, source)); + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/scourge/SulfuricVortex.java b/Mage.Sets/src/mage/sets/scourge/SulfuricVortex.java index dcccf5548f..cfb5a6f49b 100644 --- a/Mage.Sets/src/mage/sets/scourge/SulfuricVortex.java +++ b/Mage.Sets/src/mage/sets/scourge/SulfuricVortex.java @@ -28,17 +28,22 @@ package mage.sets.scourge; import java.util.UUID; +import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.Effect; +import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.continious.CantGainLifeAllEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.TargetController; import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; /** * @@ -54,10 +59,9 @@ public class SulfuricVortex extends CardImpl { // At the beginning of each player's upkeep, Sulfuric Vortex deals 2 damage to that player. this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(2, true, "that player"), TargetController.ANY, false, true)); + // If a player would gain life, that player gains no life instead. - Effect effect = new CantGainLifeAllEffect(Duration.WhileOnBattlefield); - effect.setText("If a player would gain life, that player gains no life instead"); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SulfuricVortexReplacementEffect())); } @@ -70,3 +74,41 @@ public class SulfuricVortex extends CardImpl { return new SulfuricVortex(this); } } + +class SulfuricVortexReplacementEffect extends ReplacementEffectImpl { + + public SulfuricVortexReplacementEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit); + staticText = "If a player would gain life, that player gains no life instead"; + } + + public SulfuricVortexReplacementEffect(final SulfuricVortexReplacementEffect effect) { + super(effect); + } + + @Override + public SulfuricVortexReplacementEffect copy() { + return new SulfuricVortexReplacementEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.GAIN_LIFE; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean apply(Game game, Ability source) { + return false; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + +} \ No newline at end of file diff --git a/Mage/src/mage/abilities/costs/common/GainLifeOpponentCost.java b/Mage/src/mage/abilities/costs/common/GainLifeOpponentCost.java index 3d0c08713e..31e0eaf3ed 100644 --- a/Mage/src/mage/abilities/costs/common/GainLifeOpponentCost.java +++ b/Mage/src/mage/abilities/costs/common/GainLifeOpponentCost.java @@ -28,7 +28,7 @@ public class GainLifeOpponentCost extends CostImpl { static { filter.add(new PlayerPredicate(TargetController.OPPONENT)); - filter.add(new PlayerCanGainLifePredicate()); + filter.add(new PlayerCanGainLifePredicate()); // you can't pay the costs by letting a player gain life that can't get life by rule changing effect } private final int amount;