diff --git a/Mage.Sets/src/mage/cards/b/BelunaGrandsquall.java b/Mage.Sets/src/mage/cards/b/BelunaGrandsquall.java index e2ffdc20f08..daf6ce67902 100644 --- a/Mage.Sets/src/mage/cards/b/BelunaGrandsquall.java +++ b/Mage.Sets/src/mage/cards/b/BelunaGrandsquall.java @@ -13,7 +13,6 @@ import mage.cards.Cards; import mage.constants.*; import mage.filter.FilterCard; import mage.filter.common.FilterPermanentCard; -import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.AdventurePredicate; import mage.game.Game; import mage.players.Player; @@ -66,16 +65,6 @@ public final class BelunaGrandsquall extends AdventureCard { class SeekThrillsEffect extends OneShotEffect { - private static final FilterCard filter = new FilterCard("creature, enchantment, or land card"); - - static { - filter.add(Predicates.or( - CardType.CREATURE.getPredicate(), - CardType.ENCHANTMENT.getPredicate(), - CardType.LAND.getPredicate() - )); - } - SeekThrillsEffect() { super(Outcome.Benefit); staticText = "mill seven cards. Then put all cards that have an Adventure from among the milled cards into your hand."; @@ -109,4 +98,4 @@ class SeekThrillsEffect extends OneShotEffect { return true; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/p/PicklockPrankster.java b/Mage.Sets/src/mage/cards/p/PicklockPrankster.java index 34d8d932f20..9102beaf7fd 100644 --- a/Mage.Sets/src/mage/cards/p/PicklockPrankster.java +++ b/Mage.Sets/src/mage/cards/p/PicklockPrankster.java @@ -44,7 +44,7 @@ public final class PicklockPrankster extends AdventureCard { // Free the Fae // Mill four cards. Then put an instant, sorcery, or Faerie card from among the milled cards into your hand. - this.getSpellCard().getSpellAbility().addEffect(new MillThenPutInHandEffect(4, filter, true)); + this.getSpellCard().getSpellAbility().addEffect(new MillThenPutInHandEffect(4, filter, false)); this.finalizeAdventure(); } diff --git a/Mage.Sets/src/mage/cards/t/TetzinGnomeChampion.java b/Mage.Sets/src/mage/cards/t/TetzinGnomeChampion.java index 7d20572d5fc..a4e009c31f2 100644 --- a/Mage.Sets/src/mage/cards/t/TetzinGnomeChampion.java +++ b/Mage.Sets/src/mage/cards/t/TetzinGnomeChampion.java @@ -1,31 +1,21 @@ package mage.cards.t; -import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldThisOrAnotherTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.MillThenPutInHandEffect; import mage.abilities.keyword.CraftAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; import mage.constants.SuperType; -import mage.constants.Zone; -import mage.filter.common.FilterArtifactCard; +import mage.filter.StaticFilters; import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.Predicates; import mage.filter.predicate.card.DoubleFacedCardPredicate; import mage.filter.predicate.mageobject.AnotherPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.MilledCardsEvent; -import mage.players.Player; -import mage.target.TargetCard; + +import java.util.UUID; /** * @@ -33,7 +23,7 @@ import mage.target.TargetCard; */ public class TetzinGnomeChampion extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledPermanent("another double-faced artifact"); + private static final FilterControlledPermanent filter = new FilterControlledPermanent("double-faced artifact"); static { filter.add(AnotherPredicate.instance); @@ -58,7 +48,10 @@ public class TetzinGnomeChampion extends CardImpl { this.color.setWhite(true); // Whenever Tetzin or another double-faced artifact enters the battlefield under your control, mill three cards. You may put an artifact card from among them into your hand. - this.addAbility(new EntersBattlefieldThisOrAnotherTriggeredAbility(new TetzinGnomeChampionEffect(), filter, false, true)); + this.addAbility(new EntersBattlefieldThisOrAnotherTriggeredAbility( + new MillThenPutInHandEffect(3, StaticFilters.FILTER_CARD_ARTIFACT_AN).withTextOptions("them"), + filter, false, true + )); // Craft with six artifacts 4 (4, Exile this artifact, Exile the six from among other permanents you control and/or cards from your graveyard: Return this card transformed under its owner's control. Craft only as a sorcery.) this.addAbility(new CraftAbility( @@ -77,50 +70,3 @@ public class TetzinGnomeChampion extends CardImpl { } } - -class TetzinGnomeChampionEffect extends OneShotEffect { - - TetzinGnomeChampionEffect() { - super(Outcome.Benefit); - staticText = "mill three cards. You may put an artifact card from among them into your hand."; - } - - private TetzinGnomeChampionEffect(final TetzinGnomeChampionEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - FilterArtifactCard filter = new FilterArtifactCard(); - TargetCard target = new TargetCard(Zone.GRAVEYARD, filter); - - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - GameEvent event = GameEvent.getEvent(GameEvent.EventType.MILL_CARDS, getId(), source, getId(), 3); - if (game.replaceEvent(event)) { - return false; - } - Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, event.getAmount())); - controller.moveCards(cards, Zone.GRAVEYARD, source, game); - for (Card card : cards.getCards(game)) { - game.fireEvent(GameEvent.getEvent(GameEvent.EventType.MILLED_CARD, card.getId(), source, controller.getId())); - } - game.fireEvent(new MilledCardsEvent(source, getId(), cards)); - if (target.canChoose(controller.getId(), game) - && controller.chooseUse(Outcome.Benefit, "Do you wish to keep an artifact card from among the milled cards?", source, game) - && controller.choose(Outcome.Benefit, cards, target, source, game)) { - if (target.getFirstTarget() != null) { - Card targetArtifact = game.getCard(target.getFirstTarget()); - controller.moveCardToHandWithInfo(targetArtifact, source, game, true); - } - } - return true; - } - return false; - } - - @Override - public TetzinGnomeChampionEffect copy() { - return new TetzinGnomeChampionEffect(this); - } -} diff --git a/Mage/src/main/java/mage/abilities/effects/common/MillThenPutInHandEffect.java b/Mage/src/main/java/mage/abilities/effects/common/MillThenPutInHandEffect.java index ca013bb0d83..ad8baabac05 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/MillThenPutInHandEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/MillThenPutInHandEffect.java @@ -21,36 +21,53 @@ import mage.util.CardUtil; public class MillThenPutInHandEffect extends OneShotEffect { private final int amount; - private final boolean mandatory; // If true, putting a card in hand is mandatory if possible. + private final boolean optional; private final FilterCard filter; private final Effect otherwiseEffect; + private String textFromAmong = "the milled cards"; // for text gen + /** + * @param amount number of cards to mill + * @param filter optionally select a card matching this filter from among the milled cards to put in hand + */ public MillThenPutInHandEffect(int amount, FilterCard filter) { - this(amount, filter, null); + this(amount, filter, true); } - public MillThenPutInHandEffect(int amount, FilterCard filter, boolean mandatory) { - this(amount, filter, null, mandatory); + /** + * @param amount number of cards to mill + * @param filter select a card matching this filter from among the milled cards to put in hand + * @param optional whether the selection is optional (true) or mandatory (false) + */ + public MillThenPutInHandEffect(int amount, FilterCard filter, boolean optional) { + this(amount, filter, null, optional); } + /** + * @param amount number of cards to mill + * @param filter optionally select a card matching this filter from among the milled cards to put in hand + * @param otherwiseEffect applied if no card put into hand + */ public MillThenPutInHandEffect(int amount, FilterCard filter, Effect otherwiseEffect) { - this(amount, filter, otherwiseEffect, false); + this(amount, filter, otherwiseEffect, true); + this.textFromAmong = "the cards milled this way"; } - public MillThenPutInHandEffect(int amount, FilterCard filter, Effect otherwiseEffect, boolean mandatory) { + protected MillThenPutInHandEffect(int amount, FilterCard filter, Effect otherwiseEffect, boolean optional) { super(Outcome.Benefit); this.amount = amount; this.filter = filter; - this.mandatory = mandatory; + this.optional = optional; this.otherwiseEffect = otherwiseEffect; } private MillThenPutInHandEffect(final MillThenPutInHandEffect effect) { super(effect); this.amount = effect.amount; - this.mandatory = effect.mandatory; + this.optional = effect.optional; this.filter = effect.filter; this.otherwiseEffect = effect.otherwiseEffect; + this.textFromAmong = effect.textFromAmong; } @Override @@ -68,7 +85,7 @@ public class MillThenPutInHandEffect extends OneShotEffect { if (cards.isEmpty()) { return applyOtherwiseEffect(game, source); } - TargetCard target = new TargetCard(this.mandatory ? 1 : 0, 1, Zone.ALL, filter); + TargetCard target = new TargetCard(optional ? 0 : 1, 1, Zone.ALL, filter); player.choose(Outcome.DrawCard, cards, target, source, game); Card card = game.getCard(target.getFirstTarget()); if (card == null) { @@ -88,14 +105,19 @@ public class MillThenPutInHandEffect extends OneShotEffect { } } + public MillThenPutInHandEffect withTextOptions(String fromAmong) { + this.textFromAmong = fromAmong; + return this; + } + @Override public String getText(Mode mode) { - if (staticText == null && !staticText.isEmpty()) { + if (staticText != null && !staticText.isEmpty()) { return staticText; } String text = "mill " + CardUtil.numberToText(amount) + " cards. "; - text += this.mandatory ? "Then " : "You may "; - text += "put " + filter.getMessage() + " from among the milled cards into your hand"; + text += optional ? "You may " : "Then "; + text += "put " + filter.getMessage() + " from among " + textFromAmong + " into your hand"; if (otherwiseEffect != null) { text += ". If you don't, " + otherwiseEffect.getText(mode); }