Fixed Sith Manipulator: added new effect to send target permanent to owners library (#9800)

Co-authored-by: Daniel Eberhard <daniel.h.e@gmx.de>
This commit is contained in:
Merlingilb 2023-03-04 13:51:36 +01:00 committed by GitHub
parent 409f4eb36c
commit 716e7dc18d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 2 deletions

View file

@ -8,8 +8,8 @@ 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.effects.common.ReturnToHandTargetEffect;
import mage.abilities.effects.common.ReturnToLibraryPermanentEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -40,7 +40,7 @@ public final class SithManipulator extends CardImpl {
// <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 ReturnToLibraryPermanentEffect(true)),
new EntersBattlefieldTriggeredAbility(new ReturnTargetToOwnersLibraryPermanentEffect(true)),
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");
ability.addTarget(new TargetCreaturePermanent());

View file

@ -0,0 +1,48 @@
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);
}
}