diff --git a/Mage.Sets/src/mage/cards/b/BuryInBooks.java b/Mage.Sets/src/mage/cards/b/BuryInBooks.java index 0744a3ca976..209ceae027d 100644 --- a/Mage.Sets/src/mage/cards/b/BuryInBooks.java +++ b/Mage.Sets/src/mage/cards/b/BuryInBooks.java @@ -1,21 +1,16 @@ package mage.cards.b; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.condition.Condition; import mage.abilities.condition.common.SourceTargetsPermanentCondition; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutIntoLibraryNFromTopTargetEffect; import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.common.FilterAttackingCreature; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetCreaturePermanent; import java.util.UUID; @@ -37,7 +32,7 @@ public final class BuryInBooks extends CardImpl { ).setRuleAtTheTop(true)); // Put target creature into its owner's library second from the top. - this.getSpellAbility().addEffect(new BuryInBooksEffect()); + this.getSpellAbility().addEffect(new PutIntoLibraryNFromTopTargetEffect(2)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } @@ -50,29 +45,3 @@ public final class BuryInBooks extends CardImpl { return new BuryInBooks(this); } } - -class BuryInBooksEffect extends OneShotEffect { - - BuryInBooksEffect() { - super(Outcome.Benefit); - staticText = "put target creature into its owner's library second from the top"; - } - - private BuryInBooksEffect(final BuryInBooksEffect effect) { - super(effect); - } - - @Override - public BuryInBooksEffect copy() { - return new BuryInBooksEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(source.getFirstTarget()); - return player != null - && permanent != null - && player.putCardOnTopXOfLibrary(permanent, game, source, 2, true); - } -} diff --git a/Mage.Sets/src/mage/cards/c/Chronostutter.java b/Mage.Sets/src/mage/cards/c/Chronostutter.java index a4cddea0c21..1a7878001d4 100644 --- a/Mage.Sets/src/mage/cards/c/Chronostutter.java +++ b/Mage.Sets/src/mage/cards/c/Chronostutter.java @@ -1,20 +1,14 @@ - package mage.cards.c; -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutIntoLibraryNFromTopTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetCreaturePermanent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class Chronostutter extends CardImpl { @@ -23,9 +17,8 @@ public final class Chronostutter extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{5}{U}"); // Put target creature into its owner's library second from the top. - this.getSpellAbility().addEffect(new ChronostutterEffect()); + this.getSpellAbility().addEffect(new PutIntoLibraryNFromTopTargetEffect(2)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); - } private Chronostutter(final Chronostutter card) { @@ -37,33 +30,3 @@ public final class Chronostutter extends CardImpl { return new Chronostutter(this); } } - -class ChronostutterEffect extends OneShotEffect { - - public ChronostutterEffect() { - super(Outcome.Benefit); - this.staticText = "Put target creature into its owner's library second from the top"; - } - - public ChronostutterEffect(final ChronostutterEffect effect) { - super(effect); - } - - @Override - public ChronostutterEffect copy() { - return new ChronostutterEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); - if (permanent != null) { - controller.putCardOnTopXOfLibrary(permanent, game, source, 2, true); - } - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/i/IsolationAtOrthanc.java b/Mage.Sets/src/mage/cards/i/IsolationAtOrthanc.java new file mode 100644 index 00000000000..fe28c5d3f02 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/IsolationAtOrthanc.java @@ -0,0 +1,32 @@ +package mage.cards.i; + +import mage.abilities.effects.common.PutIntoLibraryNFromTopTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.target.common.TargetCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class IsolationAtOrthanc extends CardImpl { + + public IsolationAtOrthanc(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}"); + + // Put target creature into its owner's library second from the top. + this.getSpellAbility().addEffect(new PutIntoLibraryNFromTopTargetEffect(2)); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + } + + private IsolationAtOrthanc(final IsolationAtOrthanc card) { + super(card); + } + + @Override + public IsolationAtOrthanc copy() { + return new IsolationAtOrthanc(this); + } +} diff --git a/Mage.Sets/src/mage/cards/s/SynchronizedEviction.java b/Mage.Sets/src/mage/cards/s/SynchronizedEviction.java index 32193164dcd..cb7fb72e881 100644 --- a/Mage.Sets/src/mage/cards/s/SynchronizedEviction.java +++ b/Mage.Sets/src/mage/cards/s/SynchronizedEviction.java @@ -4,16 +4,13 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.condition.Condition; import mage.abilities.dynamicvalue.common.GreatestSharedCreatureTypeCount; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutIntoLibraryNFromTopTargetEffect; import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetNonlandPermanent; import java.util.UUID; @@ -33,7 +30,7 @@ public final class SynchronizedEviction extends CardImpl { ); // Put target nonland permanent into its owner's library second from the top. - this.getSpellAbility().addEffect(new SynchronizedEvictionEffect()); + this.getSpellAbility().addEffect(new PutIntoLibraryNFromTopTargetEffect(2)); this.getSpellAbility().addTarget(new TargetNonlandPermanent()); } @@ -60,29 +57,3 @@ enum SynchronizedEvictionCondition implements Condition { return "you control at least two creatures that share a creature type"; } } - -class SynchronizedEvictionEffect extends OneShotEffect { - - SynchronizedEvictionEffect() { - super(Outcome.Benefit); - staticText = "put target nonland permanent into its owner's library second from the top"; - } - - private SynchronizedEvictionEffect(final SynchronizedEvictionEffect effect) { - super(effect); - } - - @Override - public SynchronizedEvictionEffect copy() { - return new SynchronizedEvictionEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); - return controller != null - && permanent != null - && controller.putCardOnTopXOfLibrary(permanent, game, source, 2, true); - } -} diff --git a/Mage.Sets/src/mage/cards/t/TeferiHeroOfDominaria.java b/Mage.Sets/src/mage/cards/t/TeferiHeroOfDominaria.java index 97cfd23d691..87ad9963323 100644 --- a/Mage.Sets/src/mage/cards/t/TeferiHeroOfDominaria.java +++ b/Mage.Sets/src/mage/cards/t/TeferiHeroOfDominaria.java @@ -1,28 +1,18 @@ - package mage.cards.t; -import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.LoyaltyAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; -import mage.abilities.effects.common.DrawCardSourceControllerEffect; -import mage.abilities.effects.common.GetEmblemEffect; -import mage.abilities.effects.common.UntapLandsEffect; +import mage.abilities.effects.common.*; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; import mage.constants.SuperType; -import mage.game.Game; import mage.game.command.emblems.TeferiHeroOfDominariaEmblem; -import mage.players.Player; import mage.target.common.TargetNonlandPermanent; import java.util.UUID; -import mage.game.permanent.Permanent; /** * @author LevelX2 @@ -46,7 +36,7 @@ public final class TeferiHeroOfDominaria extends CardImpl { this.addAbility(ability); // −3: Put target nonland permanent into its owner's library third from the top. - ability = new LoyaltyAbility(new TeferiHeroOfDominariaSecondEffect(), -3); + ability = new LoyaltyAbility(new PutIntoLibraryNFromTopTargetEffect(3), -3); ability.addTarget(new TargetNonlandPermanent()); this.addAbility(ability); @@ -63,33 +53,3 @@ public final class TeferiHeroOfDominaria extends CardImpl { return new TeferiHeroOfDominaria(this); } } - -class TeferiHeroOfDominariaSecondEffect extends OneShotEffect { - - public TeferiHeroOfDominariaSecondEffect() { - super(Outcome.Benefit); - this.staticText = "Put target nonland permanent into its owner's library third from the top"; - } - - public TeferiHeroOfDominariaSecondEffect(final TeferiHeroOfDominariaSecondEffect effect) { - super(effect); - } - - @Override - public TeferiHeroOfDominariaSecondEffect copy() { - return new TeferiHeroOfDominariaSecondEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); - if (permanent != null) { - controller.putCardOnTopXOfLibrary(permanent, game, source, 3, true); - } - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java index 0c6f2add26c..416f1ec66d1 100644 --- a/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java +++ b/Mage.Sets/src/mage/sets/TheLordOfTheRingsTalesOfMiddleEarth.java @@ -105,6 +105,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet { cards.add(new SetCardInfo("Ioreth of the Healing House", 56, Rarity.UNCOMMON, mage.cards.i.IorethOfTheHealingHouse.class)); cards.add(new SetCardInfo("Isildur's Fateful Strike", 91, Rarity.RARE, mage.cards.i.IsildursFatefulStrike.class)); cards.add(new SetCardInfo("Island", 264, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Isolation at Orthanc", 57, Rarity.COMMON, mage.cards.i.IsolationAtOrthanc.class)); cards.add(new SetCardInfo("Ithilien Kingfisher", 58, Rarity.COMMON, mage.cards.i.IthilienKingfisher.class)); cards.add(new SetCardInfo("Knight of the Keep", 291, Rarity.COMMON, mage.cards.k.KnightOfTheKeep.class)); cards.add(new SetCardInfo("Knights of Dol Amroth", 59, Rarity.COMMON, mage.cards.k.KnightsOfDolAmroth.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/PutIntoLibraryNFromTopTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PutIntoLibraryNFromTopTargetEffect.java new file mode 100644 index 00000000000..bc4b90ec513 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/PutIntoLibraryNFromTopTargetEffect.java @@ -0,0 +1,50 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * @author TheElk801 + */ +public class PutIntoLibraryNFromTopTargetEffect extends OneShotEffect { + + private final int position; + + public PutIntoLibraryNFromTopTargetEffect(int position) { + super(Outcome.Benefit); + this.position = position; + } + + private PutIntoLibraryNFromTopTargetEffect(final PutIntoLibraryNFromTopTargetEffect effect) { + super(effect); + this.position = effect.position; + } + + @Override + public PutIntoLibraryNFromTopTargetEffect copy() { + return new PutIntoLibraryNFromTopTargetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + return player != null && permanent != null + && player.putCardOnTopXOfLibrary(permanent, game, source, position, true); + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + return "put " + getTargetPointer().describeTargets(mode.getTargets(), "") + + " into its owner's library " + CardUtil.numberToOrdinalText(position) + " from the top"; + } +}