From 62062367e209998308cbbcb783b2871ae0ae2de0 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 12 Jan 2020 13:19:09 +0100 Subject: [PATCH] Implemented Furious Rise. --- Mage.Sets/src/mage/cards/f/FuriousRise.java | 136 ++++++++++++++++++ .../src/mage/sets/TherosBeyondDeath.java | 1 + .../abilities/effects/ContinuousEffects.java | 4 + 3 files changed, 141 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FuriousRise.java diff --git a/Mage.Sets/src/mage/cards/f/FuriousRise.java b/Mage.Sets/src/mage/cards/f/FuriousRise.java new file mode 100644 index 0000000000..0ef4796198 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FuriousRise.java @@ -0,0 +1,136 @@ +package mage.cards.f; + +import java.util.List; +import java.util.UUID; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.condition.common.FerociousCondition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.AsThoughEffect; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.AsThoughEffectType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.game.Game; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; +import mage.util.CardUtil; + +/** + * + * @author LevelX2 + */ +public final class FuriousRise extends CardImpl { + + public FuriousRise(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}"); + + // At the beginning of your end step, if you control a creature with power 4 or greater, exile the top card of your library. + // You may play that card until you exile another card with Furious Rise. + this.addAbility(new ConditionalInterveningIfTriggeredAbility(new BeginningOfEndStepTriggeredAbility( + new FuriousRiseEffect(), TargetController.YOU, false), FerociousCondition.instance, + "At the beginning of your end step, if you control a creature with power 4 or greater, exile the top card of your library. You may play that card until you exile another card with {this}.")); + } + + private FuriousRise(final FuriousRise card) { + super(card); + } + + @Override + public FuriousRise copy() { + return new FuriousRise(this); + } +} + +class FuriousRiseEffect extends OneShotEffect { + + public FuriousRiseEffect() { + super(Outcome.Benefit); + this.staticText = "exile the top card of your library. You may play that card until you exile another card with Furious Rise"; + } + + public FuriousRiseEffect(final FuriousRiseEffect effect) { + super(effect); + } + + @Override + public FuriousRiseEffect copy() { + return new FuriousRiseEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + MageObject mageObject = source.getSourceObject(game); + if (controller != null && mageObject != null) { + Card cardToExile = controller.getLibrary().getFromTop(game); + + UUID exileId = CardUtil.getCardExileZoneId(game, source); + controller.moveCardsToExile(cardToExile, source, game, true, exileId, mageObject.getIdName() + " (" + source.getSourceObjectZoneChangeCounter() + ")"); + Card cardToPlay = game.getCard(cardToExile.getId()); + + endPreviousEffect(game, source); + + ContinuousEffect effect = new FuriousRisePlayEffect(); + effect.setTargetPointer(new FixedTarget(cardToPlay, game)); + game.addEffect(effect, source); + return true; + } + return false; + } + + private static boolean endPreviousEffect(Game game, Ability source) { + for (AsThoughEffect effect : game.getContinuousEffects().getApplicableAsThoughEffects(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, game)) { + if (effect instanceof FuriousRisePlayEffect) { + for (Ability ability : game.getContinuousEffects().getAsThoughEffectsAbility(effect)) { + if (ability.getSourceId().equals(source.getSourceId()) + && source.getSourceObjectZoneChangeCounter() == ability.getSourceObjectZoneChangeCounter()) { + ((FuriousRisePlayEffect) effect).discard(); + return true; + } + } + } + } + return false; + } +} + +class FuriousRisePlayEffect extends AsThoughEffectImpl { + + public FuriousRisePlayEffect() { + super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.Custom, Outcome.Benefit); + } + + public FuriousRisePlayEffect(final FuriousRisePlayEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public FuriousRisePlayEffect copy() { + return new FuriousRisePlayEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + List targets = getTargetPointer().getTargets(game, source); + if (targets.isEmpty()) { + this.discard(); + return false; + } + return targets.contains(objectId) + && affectedControllerId.equals(source.getControllerId()); + } +} diff --git a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java index 01978f47d3..b4939a3cfc 100644 --- a/Mage.Sets/src/mage/sets/TherosBeyondDeath.java +++ b/Mage.Sets/src/mage/sets/TherosBeyondDeath.java @@ -102,6 +102,7 @@ public final class TherosBeyondDeath extends ExpansionSet { cards.add(new SetCardInfo("Forest", 254, Rarity.LAND, mage.cards.basiclands.Forest.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Fruit of Tizerus", 96, Rarity.COMMON, mage.cards.f.FruitOfTizerus.class)); cards.add(new SetCardInfo("Funeral Rites", 97, Rarity.COMMON, mage.cards.f.FuneralRites.class)); + cards.add(new SetCardInfo("Furious Rise", 136, Rarity.UNCOMMON, mage.cards.f.FuriousRise.class)); cards.add(new SetCardInfo("Gallia of the Endless Dance", 217, Rarity.RARE, mage.cards.g.GalliaOfTheEndlessDance.class)); cards.add(new SetCardInfo("Gift of Strength", 171, Rarity.COMMON, mage.cards.g.GiftOfStrength.class)); cards.add(new SetCardInfo("Glimpse of Freedom", 50, Rarity.UNCOMMON, mage.cards.g.GlimpseOfFreedom.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java index 72a0d7ba87..c8a42c6a05 100644 --- a/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java +++ b/Mage/src/main/java/mage/abilities/effects/ContinuousEffects.java @@ -597,6 +597,10 @@ public class ContinuousEffects implements Serializable { return asThoughEffectsList; } + public Set getAsThoughEffectsAbility(AsThoughEffect effect) { + return asThoughEffectsMap.get(effect.getAsThoughEffectType()).getAbility(effect.getId()); + } + /** * 601.2e The player determines the total cost of the spell. Usually this is * just the mana cost. Some spells have additional or alternative costs.