From 7e15ca92c5cba02f5ea83d2f8ecf68b17aadf19a Mon Sep 17 00:00:00 2001 From: xenohedron Date: Fri, 23 Jun 2023 20:11:37 -0400 Subject: [PATCH] simplify implementation and remove redundant class --- .../src/mage/cards/s/SithManipulator.java | 24 +++++----- ...nTargetToOwnersLibraryPermanentEffect.java | 48 ------------------- 2 files changed, 11 insertions(+), 61 deletions(-) delete mode 100644 Mage/src/main/java/mage/abilities/effects/common/ReturnTargetToOwnersLibraryPermanentEffect.java diff --git a/Mage.Sets/src/mage/cards/s/SithManipulator.java b/Mage.Sets/src/mage/cards/s/SithManipulator.java index 74843ba736..ba04ce024f 100644 --- a/Mage.Sets/src/mage/cards/s/SithManipulator.java +++ b/Mage.Sets/src/mage/cards/s/SithManipulator.java @@ -5,10 +5,10 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.condition.InvertCondition; import mage.abilities.condition.common.HateCondition; -import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; -import mage.abilities.effects.common.ReturnTargetToOwnersLibraryPermanentEffect; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.PutOnLibraryTargetEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -31,18 +31,16 @@ public final class SithManipulator extends CardImpl { this.toughness = new MageInt(2); // When Sith Manipulator enters the battlefield, return target creature to its owner's hand. - Ability ability = new ConditionalInterveningIfTriggeredAbility( - new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect()), - new InvertCondition(HateCondition.instance), - "When Sith Manipulator enters the battlefield, return target creature to its owner's hand"); - ability.addTarget(new TargetCreaturePermanent()); - this.addAbility(ability, new LifeLossOtherFromCombatWatcher()); - // Hate — If opponent lost life from source other than combat damage this turn, put that card on top of its owner's library instead. - ability = new ConditionalInterveningIfTriggeredAbility( - new EntersBattlefieldTriggeredAbility(new ReturnTargetToOwnersLibraryPermanentEffect(true)), + Effect effect = new ConditionalOneShotEffect( + new PutOnLibraryTargetEffect(true), + new ReturnToHandTargetEffect(), HateCondition.instance, - "Hate — If opponent lost life from source other than combat damage this turn, put that card on top of its owner's library instead"); + "return target creature to its owner's hand." + + "
Hate — If opponent lost life from source other than combat damage this turn, " + + "put that card on top of its owner's library instead" + ); + Ability ability = new EntersBattlefieldTriggeredAbility(effect); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability, new LifeLossOtherFromCombatWatcher()); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnTargetToOwnersLibraryPermanentEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnTargetToOwnersLibraryPermanentEffect.java deleted file mode 100644 index 3c2e73b450..0000000000 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnTargetToOwnersLibraryPermanentEffect.java +++ /dev/null @@ -1,48 +0,0 @@ - -package mage.abilities.effects.common; - -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.constants.Outcome; -import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; - -/** - * - * @author Merlingilb - */ -public class ReturnTargetToOwnersLibraryPermanentEffect extends OneShotEffect { - - private final boolean toTop; - - public ReturnTargetToOwnersLibraryPermanentEffect(boolean top) { - super(Outcome.Neutral); - staticText = "Put target card on "+ (top ? "top":"the bottom") + " of its owner's library"; - this.toTop = top; - } - - public ReturnTargetToOwnersLibraryPermanentEffect(final ReturnTargetToOwnersLibraryPermanentEffect effect) { - super(effect); - this.toTop = effect.toTop; - } - - @Override - public boolean apply(Game game, Ability source) { - Card card = game.getPermanent(source.getFirstTarget()); - if (card != null) { - Player owner = game.getPlayer(card.getOwnerId()); - if (owner != null) { - owner.moveCardToLibraryWithInfo(card, source, game, Zone.STACK, toTop, true); - } - return true; - } - return false; - } - - @Override - public ReturnTargetToOwnersLibraryPermanentEffect copy() { - return new ReturnTargetToOwnersLibraryPermanentEffect(this); - } -}