forked from External/mage
Minor changes to the framework.
This commit is contained in:
parent
00b03c91b6
commit
a5063ef9ee
4 changed files with 171 additions and 5 deletions
|
|
@ -30,6 +30,8 @@ package mage.abilities.effects.common;
|
|||
|
||||
import mage.constants.Outcome;
|
||||
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.constants.Zone;
|
||||
|
|
@ -44,9 +46,12 @@ import mage.util.CardUtil;
|
|||
|
||||
public class PutTopCardOfTargetPlayerLibraryIntoGraveEffect extends OneShotEffect<PutTopCardOfTargetPlayerLibraryIntoGraveEffect> {
|
||||
|
||||
private int numberCards;
|
||||
private DynamicValue numberCards;
|
||||
|
||||
public PutTopCardOfTargetPlayerLibraryIntoGraveEffect(int numberCards) {
|
||||
this(new StaticValue(numberCards));
|
||||
}
|
||||
public PutTopCardOfTargetPlayerLibraryIntoGraveEffect(DynamicValue numberCards) {
|
||||
super(Outcome.Discard);
|
||||
this.numberCards = numberCards;
|
||||
this.staticText = setText();
|
||||
|
|
@ -66,7 +71,7 @@ public class PutTopCardOfTargetPlayerLibraryIntoGraveEffect extends OneShotEffec
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
int cardsCount = Math.min(numberCards, player.getLibrary().size());
|
||||
int cardsCount = Math.min(numberCards.calculate(game, source), player.getLibrary().size());
|
||||
for (int i = 0; i < cardsCount; i++) {
|
||||
Card card = player.getLibrary().removeFromTop(game);
|
||||
if (card != null) {
|
||||
|
|
@ -80,10 +85,10 @@ public class PutTopCardOfTargetPlayerLibraryIntoGraveEffect extends OneShotEffec
|
|||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("Target player puts the top ");
|
||||
if (numberCards == 1) {
|
||||
if (numberCards.toString().equals("1")) {
|
||||
sb.append(" card");
|
||||
} else {
|
||||
sb.append(CardUtil.numberToText(numberCards));
|
||||
sb.append(CardUtil.numberToText(numberCards.toString()));
|
||||
sb.append(" cards");
|
||||
}
|
||||
sb.append(" of his or her library into his or her graveyard");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue