[ODY] fixed Aven Windreader effect #7733

This commit is contained in:
Evan Kranzler 2021-04-11 09:32:01 -04:00
parent d31b7bb815
commit ed7a91cd60
2 changed files with 37 additions and 78 deletions

View file

@ -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;
}
}

View file

@ -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();
}
}