From 8eb8a163af91319858e92a006f2ecb7250fc7311 Mon Sep 17 00:00:00 2001 From: xenohedron Date: Sat, 13 May 2023 19:40:52 -0400 Subject: [PATCH] Cleanup SearchLibraryPutInPlayTargetPlayerEffect --- Mage.Sets/src/mage/cards/f/Fertilid.java | 2 +- .../src/mage/cards/f/FertilidsFavor.java | 2 +- Mage.Sets/src/mage/cards/o/OathOfLieges.java | 2 +- .../src/mage/cards/p/PatternOfRebirth.java | 2 +- ...rchLibraryPutInPlayTargetPlayerEffect.java | 40 +++++-------------- 5 files changed, 15 insertions(+), 33 deletions(-) diff --git a/Mage.Sets/src/mage/cards/f/Fertilid.java b/Mage.Sets/src/mage/cards/f/Fertilid.java index c559174d17..49db6eec8a 100644 --- a/Mage.Sets/src/mage/cards/f/Fertilid.java +++ b/Mage.Sets/src/mage/cards/f/Fertilid.java @@ -38,7 +38,7 @@ public final class Fertilid extends CardImpl { // {1}{G}, Remove a +1/+1 counter from Fertilid: Target player searches their library for a basic land card and puts it onto the battlefield tapped. Then that player shuffles their library. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), true, true), new ManaCostsImpl<>("{1}{G}")); + new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), true), new ManaCostsImpl<>("{1}{G}")); ability.addCost(new RemoveCountersSourceCost(CounterType.P1P1.createInstance(1))); ability.addTarget(new TargetPlayer()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/f/FertilidsFavor.java b/Mage.Sets/src/mage/cards/f/FertilidsFavor.java index 875cafb03d..0622336a59 100644 --- a/Mage.Sets/src/mage/cards/f/FertilidsFavor.java +++ b/Mage.Sets/src/mage/cards/f/FertilidsFavor.java @@ -24,7 +24,7 @@ public final class FertilidsFavor extends CardImpl { // Target player searches their library for a basic land card, puts it onto the battlefield tapped, then shuffles. Put two +1/+1 counters on up to one target artifact or creature. this.getSpellAbility().addEffect(new SearchLibraryPutInPlayTargetPlayerEffect( - new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), true, true + new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), true )); this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(2)) diff --git a/Mage.Sets/src/mage/cards/o/OathOfLieges.java b/Mage.Sets/src/mage/cards/o/OathOfLieges.java index d09d554698..1945563329 100644 --- a/Mage.Sets/src/mage/cards/o/OathOfLieges.java +++ b/Mage.Sets/src/mage/cards/o/OathOfLieges.java @@ -89,7 +89,7 @@ class OathOfLiegesEffect extends OneShotEffect { Player activePlayer = game.getPlayer(game.getActivePlayerId()); if (activePlayer != null) { if (activePlayer.chooseUse(outcome, "Search your library for a basic land card, put that card onto the battlefield, then shuffle?", source, game)) { - Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, false, Outcome.PutLandInPlay, true); + Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND), false, true); effect.setTargetPointer(new FixedTarget(game.getActivePlayerId())); return effect.apply(game, source); } diff --git a/Mage.Sets/src/mage/cards/p/PatternOfRebirth.java b/Mage.Sets/src/mage/cards/p/PatternOfRebirth.java index e1ddcefca8..cdc6edf373 100644 --- a/Mage.Sets/src/mage/cards/p/PatternOfRebirth.java +++ b/Mage.Sets/src/mage/cards/p/PatternOfRebirth.java @@ -35,7 +35,7 @@ public final class PatternOfRebirth extends CardImpl { this.addAbility(ability); // When enchanted creature dies, that creature's controller may search their library for a creature card and put that card onto the battlefield. If that player does, they shuffle their library. - Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_CREATURE), false, false, Outcome.PutCreatureInPlay); + Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(StaticFilters.FILTER_CARD_CREATURE), false); effect.setText("that creature's controller may search their library for a creature card and put that card onto the battlefield. If that player does, they shuffle"); this.addAbility(new DiesAttachedTriggeredAbility(effect, "enchanted creature", true, true, SetTargetPointer.ATTACHED_TO_CONTROLLER)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/search/SearchLibraryPutInPlayTargetPlayerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/search/SearchLibraryPutInPlayTargetPlayerEffect.java index 1faafb41da..b3640058a3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/search/SearchLibraryPutInPlayTargetPlayerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/search/SearchLibraryPutInPlayTargetPlayerEffect.java @@ -16,40 +16,26 @@ import mage.target.common.TargetCardInLibrary; public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { protected boolean tapped; - protected boolean forceShuffle; protected boolean ownerIsController; - public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target) { - this(target, false, true, Outcome.PutCardInPlay); - } - public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped) { - this(target, tapped, true, Outcome.PutCardInPlay); + this(target, tapped, false); } - public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle) { - this(target, tapped, forceShuffle, Outcome.PutCardInPlay); - } - - public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, Outcome outcome) { - this(target, tapped, true, outcome); - } - - public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle, Outcome outcome) { - this(target, tapped, forceShuffle, outcome, false); - } - - public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle, Outcome outcome, boolean ownerIsController) { - super(target, outcome); + public SearchLibraryPutInPlayTargetPlayerEffect(TargetCardInLibrary target, boolean tapped, boolean ownerIsController) { + super(target, Outcome.PutCardInPlay); this.tapped = tapped; - this.forceShuffle = forceShuffle; this.ownerIsController = ownerIsController; + if (target.getDescription().contains("land")) { + this.outcome = Outcome.PutLandInPlay; + } else if (target.getDescription().contains("creature")) { + this.outcome = Outcome.PutCreatureInPlay; + } } public SearchLibraryPutInPlayTargetPlayerEffect(final SearchLibraryPutInPlayTargetPlayerEffect effect) { super(effect); this.tapped = effect.tapped; - this.forceShuffle = effect.forceShuffle; this.ownerIsController = effect.ownerIsController; } @@ -70,12 +56,8 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { player.shuffleLibrary(source, game); return true; } - - if (forceShuffle) { - player.shuffleLibrary(source, game); - } + player.shuffleLibrary(source, game); } - return false; } @@ -87,9 +69,9 @@ public class SearchLibraryPutInPlayTargetPlayerEffect extends SearchEffect { return getTargetPointer().describeTargets(mode.getTargets(), "that player") + " searches their library for " + target.getDescription() - + (forceShuffle ? ", " : " and ") + + ", " + (target.getMaxNumberOfTargets() > 1 ? "puts them onto the battlefield" : "puts it onto the battlefield") + (tapped ? " tapped" : "") - + (forceShuffle ? ", then shuffles" : ". If that player does, they shuffle"); + + ", then shuffles"; } }