simplify implementation and remove redundant class

This commit is contained in:
xenohedron 2023-06-23 20:11:37 -04:00
parent 23a6185f70
commit 7e15ca92c5
2 changed files with 11 additions and 61 deletions

View file

@ -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());
// <i>Hate</i> &mdash; 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,
"<i>Hate</i> &mdash; 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." +
"<br><i>Hate</i> &mdash; 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());

View file

@ -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);
}
}