From 64962c63eb3a4decdd49c4770732a1012923a0e3 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 27 Jan 2019 10:09:52 -0500 Subject: [PATCH] Implemented Razor Pendulum --- Mage.Sets/src/mage/cards/r/RazorPendulum.java | 82 +++++++++++++++++++ Mage.Sets/src/mage/sets/Mirage.java | 1 + 2 files changed, 83 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RazorPendulum.java diff --git a/Mage.Sets/src/mage/cards/r/RazorPendulum.java b/Mage.Sets/src/mage/cards/r/RazorPendulum.java new file mode 100644 index 0000000000..0c5d1f7151 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RazorPendulum.java @@ -0,0 +1,82 @@ +package mage.cards.r; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RazorPendulum extends CardImpl { + + public RazorPendulum(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); + + + // At the beginning of each player’s end step, if that player has 5 or less life, Razor Pendulum deals 2 damage to that player. + this.addAbility(new ConditionalInterveningIfTriggeredAbility( + new BeginningOfEndStepTriggeredAbility( + new RazorPendulumEffect(), TargetController.ANY, false + ), RazorPendulumCondition.instance, "At the beginning of each player's end step, " + + "if that player has 5 or less life, {this} deals 2 damage to that player." + )); + } + + private RazorPendulum(final RazorPendulum card) { + super(card); + } + + @Override + public RazorPendulum copy() { + return new RazorPendulum(this); + } +} + +class RazorPendulumEffect extends OneShotEffect { + + RazorPendulumEffect() { + super(Outcome.Benefit); + } + + private RazorPendulumEffect(final RazorPendulumEffect effect) { + super(effect); + } + + @Override + public RazorPendulumEffect copy() { + return new RazorPendulumEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(game.getActivePlayerId()); + if (player == null) { + return false; + } + return player.damage(2, source.getSourceId(), game) > 0; + } +} + +enum RazorPendulumCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(game.getActivePlayerId()); + if (player == null) { + return false; + } + return player.getLife() < 6; + } +} diff --git a/Mage.Sets/src/mage/sets/Mirage.java b/Mage.Sets/src/mage/sets/Mirage.java index 7cf322e6b8..ee165fb5d9 100644 --- a/Mage.Sets/src/mage/sets/Mirage.java +++ b/Mage.Sets/src/mage/sets/Mirage.java @@ -237,6 +237,7 @@ public final class Mirage extends ExpansionSet { cards.add(new SetCardInfo("Rashida Scalebane", 35, Rarity.RARE, mage.cards.r.RashidaScalebane.class)); cards.add(new SetCardInfo("Ravenous Vampire", 136, Rarity.UNCOMMON, mage.cards.r.RavenousVampire.class)); cards.add(new SetCardInfo("Ray of Command", 86, Rarity.COMMON, mage.cards.r.RayOfCommand.class)); + cards.add(new SetCardInfo("Razor Pendulum", 317, Rarity.RARE, mage.cards.r.RazorPendulum.class)); cards.add(new SetCardInfo("Reality Ripple", 87, Rarity.COMMON, mage.cards.r.RealityRipple.class)); cards.add(new SetCardInfo("Reckless Embermage", 189, Rarity.RARE, mage.cards.r.RecklessEmbermage.class)); cards.add(new SetCardInfo("Regeneration", 236, Rarity.COMMON, mage.cards.r.Regeneration.class));