From ed7a91cd60c843e8d0304e129b51a733d14affd1 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 11 Apr 2021 09:32:01 -0400 Subject: [PATCH] [ODY] fixed Aven Windreader effect #7733 --- .../src/mage/cards/a/AvenWindreader.java | 45 +++++++++--- .../RevealTargetPlayerLibraryEffect.java | 70 ------------------- 2 files changed, 37 insertions(+), 78 deletions(-) delete mode 100644 Mage/src/main/java/mage/abilities/effects/common/RevealTargetPlayerLibraryEffect.java diff --git a/Mage.Sets/src/mage/cards/a/AvenWindreader.java b/Mage.Sets/src/mage/cards/a/AvenWindreader.java index 495e0e2edd..31418007ea 100644 --- a/Mage.Sets/src/mage/cards/a/AvenWindreader.java +++ b/Mage.Sets/src/mage/cards/a/AvenWindreader.java @@ -1,28 +1,30 @@ - package mage.cards.a; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.common.RevealTargetPlayerLibraryEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; import mage.constants.CardType; +import mage.constants.Outcome; import mage.constants.SubType; -import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; import mage.target.TargetPlayer; +import java.util.UUID; + /** - * - * @author cbt33 + * @author TheElk801 */ public final class AvenWindreader extends CardImpl { public AvenWindreader(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{U}{U}"); this.subtype.add(SubType.BIRD); this.subtype.add(SubType.SOLDIER); this.subtype.add(SubType.WIZARD); @@ -34,7 +36,7 @@ public final class AvenWindreader extends CardImpl { this.addAbility(FlyingAbility.getInstance()); // {1}{U}: Target player reveals the top card of their library. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealTargetPlayerLibraryEffect(1), new ManaCostsImpl("{1}{U}")); + Ability ability = new SimpleActivatedAbility(new AvenWindreaderEffect(), new ManaCostsImpl("{1}{U}")); ability.addTarget(new TargetPlayer()); this.addAbility(ability); } @@ -48,3 +50,30 @@ public final class AvenWindreader extends CardImpl { return new AvenWindreader(this); } } + +class AvenWindreaderEffect extends OneShotEffect { + + AvenWindreaderEffect() { + super(Outcome.Benefit); + staticText = "target player reveals the top card of their library"; + } + + private AvenWindreaderEffect(final AvenWindreaderEffect effect) { + super(effect); + } + + @Override + public AvenWindreaderEffect copy() { + return new AvenWindreaderEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getFirstTarget()); + if (player == null) { + return false; + } + player.revealCards(source, new CardsImpl(player.getLibrary().getFromTop(game)), game); + return true; + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/RevealTargetPlayerLibraryEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RevealTargetPlayerLibraryEffect.java deleted file mode 100644 index afb199ca96..0000000000 --- a/Mage/src/main/java/mage/abilities/effects/common/RevealTargetPlayerLibraryEffect.java +++ /dev/null @@ -1,70 +0,0 @@ - -package mage.abilities.effects.common; - -import mage.MageObject; -import mage.abilities.Ability; -import mage.abilities.dynamicvalue.DynamicValue; -import mage.abilities.dynamicvalue.common.StaticValue; -import mage.abilities.effects.OneShotEffect; -import mage.cards.Cards; -import mage.cards.CardsImpl; -import mage.constants.Outcome; -import mage.game.Game; -import mage.players.Player; -import mage.util.CardUtil; - -/** - * - * @author Luna Skyrise - */ -public class RevealTargetPlayerLibraryEffect extends OneShotEffect { - - private DynamicValue amountCards; - - public RevealTargetPlayerLibraryEffect(int amountCards) { - this(StaticValue.get(amountCards)); - } - - public RevealTargetPlayerLibraryEffect(DynamicValue amountCards) { - super(Outcome.Neutral); - this.amountCards = amountCards; - this.staticText = setText(); - } - - public RevealTargetPlayerLibraryEffect(final RevealTargetPlayerLibraryEffect effect) { - super(effect); - this.amountCards = effect.amountCards; - } - - @Override - public RevealTargetPlayerLibraryEffect copy() { - return new RevealTargetPlayerLibraryEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Player targetPlayer = game.getPlayer(source.getFirstTarget()); - MageObject sourceObject = source.getSourceObject(game); - if (player == null || targetPlayer == null || sourceObject == null) { - return false; - } - - Cards cards = new CardsImpl(); - cards.addAll(player.getLibrary().getTopCards(game, amountCards.calculate(game, source, this))); - player.revealCards(sourceObject.getIdName() + " - Top " + amountCards.toString() + "cards of " + targetPlayer.getName() + "\'s library", cards, game); - return true; - } - - private String setText() { - String number = amountCards.toString(); - StringBuilder sb = new StringBuilder("Reveal the top "); - if ("1".equals(number)) { - sb.append("card"); - } else { - sb.append(CardUtil.numberToText(number)).append(" cards"); - } - sb.append(" of target player's library."); - return sb.toString(); - } -}