mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
[ODY] fixed Aven Windreader effect #7733
This commit is contained in:
parent
d31b7bb815
commit
ed7a91cd60
2 changed files with 37 additions and 78 deletions
|
@ -1,23 +1,25 @@
|
|||
|
||||
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 {
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue