diff --git a/Mage.Sets/src/mage/sets/ninthedition/AvenWindreader.java b/Mage.Sets/src/mage/sets/ninthedition/AvenWindreader.java index 1c4b2d5ec6c..f2df72e840b 100644 --- a/Mage.Sets/src/mage/sets/ninthedition/AvenWindreader.java +++ b/Mage.Sets/src/mage/sets/ninthedition/AvenWindreader.java @@ -32,16 +32,12 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.RevealTargetPlayerLibraryEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; -import mage.cards.CardsImpl; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; -import mage.game.Game; -import mage.players.Player; import mage.target.TargetPlayer; /** @@ -62,8 +58,9 @@ public class AvenWindreader extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); + // {1}{U}: Target player reveals the top card of his or her library. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealTopCardTargetPlayerEffect(), new ManaCostsImpl("{1}{U}")); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealTargetPlayerLibraryEffect(1), new ManaCostsImpl("{1}{U}")); ability.addTarget(new TargetPlayer()); this.addAbility(ability); } @@ -77,31 +74,3 @@ public class AvenWindreader extends CardImpl { return new AvenWindreader(this); } } - -class RevealTopCardTargetPlayerEffect extends OneShotEffect { - - public RevealTopCardTargetPlayerEffect() { - super(Outcome.Benefit); - this.staticText = "Target player reveals the top card of his or her library."; - } - - public RevealTopCardTargetPlayerEffect(final RevealTopCardTargetPlayerEffect effect) { - super(effect); - } - - @Override - public RevealTopCardTargetPlayerEffect copy() { - return new RevealTopCardTargetPlayerEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getFirstTarget()); - if (player != null) { - CardsImpl cards = new CardsImpl(); - cards.add(player.getLibrary().removeFromTop(game)); - player.revealCards("Top card of target player's library", cards, game); - } - return false; - } -} diff --git a/Mage/src/mage/abilities/effects/common/RevealTargetPlayerLibraryEffect.java b/Mage/src/mage/abilities/effects/common/RevealTargetPlayerLibraryEffect.java index c2a40e79706..5fb44e58499 100644 --- a/Mage/src/mage/abilities/effects/common/RevealTargetPlayerLibraryEffect.java +++ b/Mage/src/mage/abilities/effects/common/RevealTargetPlayerLibraryEffect.java @@ -27,11 +27,11 @@ */ 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.Card; import mage.cards.Cards; import mage.cards.CardsImpl; import mage.constants.Outcome; @@ -42,9 +42,8 @@ import mage.util.CardUtil; /** * - * @author anonymous + * @author Luna Skyrise */ - public class RevealTargetPlayerLibraryEffect extends OneShotEffect { private DynamicValue amountCards; @@ -73,28 +72,18 @@ public class RevealTargetPlayerLibraryEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); - - if (player == null || targetPlayer == null) { + MageObject sourceObject = source.getSourceObject(game); + if (player == null || targetPlayer == null || sourceObject == null) { return false; } Cards cards = new CardsImpl(Zone.LIBRARY); - int count = Math.min(targetPlayer.getLibrary().size(), amountCards.calculate(game, source, this)); - for (int i = 0; i < count; i++) { - Card card = targetPlayer.getLibrary().removeFromTop(game); - if (card != null) { - cards.add(card); - } - } - - player.lookAtCards("Top " + amountCards.toString() + "cards of " + targetPlayer.getName() + "\'s library", cards, game); - + 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() { - StringBuilder sb = new StringBuilder("Reveal the top "); - sb.append(CardUtil.numberToText(amountCards.toString())).append(" cards of target player's library."); - return sb.toString(); + return "Reveal the top " + CardUtil.numberToText(amountCards.toString()) + " cards of target player's library."; } }