From c5617cf09aef84700783ea7482968171ab023f44 Mon Sep 17 00:00:00 2001 From: LoneFox Date: Wed, 4 Nov 2015 10:41:10 +0200 Subject: [PATCH] Remove unnecessary custom effect class from Divine Offering. Implement card: Serene Offering --- .../sets/mirrodinbesieged/DivineOffering.java | 56 +++------------- .../src/mage/sets/tempest/SereneOffering.java | 66 +++++++++++++++++++ 2 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 Mage.Sets/src/mage/sets/tempest/SereneOffering.java diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/DivineOffering.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/DivineOffering.java index 8dd821a21b1..f0f805c5b06 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/DivineOffering.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/DivineOffering.java @@ -28,19 +28,14 @@ package mage.sets.mirrodinbesieged; import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.dynamicvalue.common.TargetConvertedManaCost; +import mage.abilities.effects.Effect; import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.GainLifeEffect; import mage.cards.CardImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; -import mage.filter.FilterPermanent; -import mage.filter.predicate.mageobject.CardTypePredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; -import mage.target.TargetPermanent; +import mage.target.common.TargetArtifactPermanent; /** * @@ -48,21 +43,17 @@ import mage.target.TargetPermanent; */ public class DivineOffering extends CardImpl { - private final static FilterPermanent filter = new FilterPermanent("artifact"); - - static { - filter.add(new CardTypePredicate(CardType.ARTIFACT)); - } - public DivineOffering(UUID ownerId) { super(ownerId, 5, "Divine Offering", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{W}"); this.expansionSetCode = "MBS"; // Destroy target artifact. You gain life equal to its converted mana cost. - this.getSpellAbility().addTarget(new TargetPermanent(filter)); this.getSpellAbility().addEffect(new DestroyTargetEffect()); - this.getSpellAbility().addEffect(new DivineOfferingEffect()); + Effect effect = new GainLifeEffect(new TargetConvertedManaCost()); + effect.setText("You gain life equal to its converted mana cost"); + this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addTarget(new TargetArtifactPermanent()); } public DivineOffering(final DivineOffering card) { @@ -73,35 +64,4 @@ public class DivineOffering extends CardImpl { public DivineOffering copy() { return new DivineOffering(this); } - - private class DivineOfferingEffect extends OneShotEffect { - - public DivineOfferingEffect() { - super(Outcome.DestroyPermanent); - staticText = "You gain life equal to its converted mana cost"; - } - - public DivineOfferingEffect(DivineOfferingEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent artifact = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); - if (artifact != null) { - int cost = artifact.getManaCost().convertedManaCost(); - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.gainLife(cost, game); - } - } - return true; - } - - @Override - public DivineOfferingEffect copy() { - return new DivineOfferingEffect(this); - } - - } } diff --git a/Mage.Sets/src/mage/sets/tempest/SereneOffering.java b/Mage.Sets/src/mage/sets/tempest/SereneOffering.java new file mode 100644 index 00000000000..c0d9c5746b2 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tempest/SereneOffering.java @@ -0,0 +1,66 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.tempest; + +import java.util.UUID; +import mage.abilities.dynamicvalue.common.TargetConvertedManaCost; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.target.common.TargetEnchantmentPermanent; + +/** + * + * @author LoneFox + */ +public class SereneOffering extends CardImpl { + + public SereneOffering(UUID ownerId) { + super(ownerId, 252, "Serene Offering", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{1}{W}"); + this.expansionSetCode = "TMP"; + + // Destroy target enchantment. You gain life equal to its converted mana cost. + this.getSpellAbility().addEffect(new DestroyTargetEffect()); + Effect effect = new GainLifeEffect(new TargetConvertedManaCost()); + effect.setText("You gain life equal to its converted mana cost"); + this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addTarget(new TargetEnchantmentPermanent()); + } + + public SereneOffering(final SereneOffering card) { + super(card); + } + + @Override + public SereneOffering copy() { + return new SereneOffering(this); + } +}