From 859f068e590e71d1b33c4155abd1bb3bcbd8b5ac Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 17 Nov 2013 08:31:29 +0100 Subject: [PATCH] * DrawCardTargetEffect - Added UpTo option to allow the player to select how many cards to draw. --- .../effects/common/DrawCardTargetEffect.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Mage/src/mage/abilities/effects/common/DrawCardTargetEffect.java b/Mage/src/mage/abilities/effects/common/DrawCardTargetEffect.java index a5af426d2d0..8d4a3d3ec4b 100644 --- a/Mage/src/mage/abilities/effects/common/DrawCardTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/DrawCardTargetEffect.java @@ -46,6 +46,7 @@ public class DrawCardTargetEffect extends OneShotEffect { protected DynamicValue amount; protected boolean optional; + protected boolean upTo; public DrawCardTargetEffect(int amount) { this(new StaticValue(amount)); @@ -57,16 +58,23 @@ public class DrawCardTargetEffect extends OneShotEffect { public DrawCardTargetEffect(DynamicValue amount) { this(amount, false); } + public DrawCardTargetEffect(DynamicValue amount, boolean optional) { + this(amount, optional, false); + } + + public DrawCardTargetEffect(DynamicValue amount, boolean optional, boolean upto) { super(Outcome.DrawCard); this.amount = amount.copy(); this.optional = optional; + this.upTo = upto; } public DrawCardTargetEffect(final DrawCardTargetEffect effect) { super(effect); this.amount = effect.amount.copy(); this.optional = effect.optional; + this.upTo = effect.upTo; } @Override @@ -78,8 +86,12 @@ public class DrawCardTargetEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { + int cardsToDraw = amount.calculate(game, source); + if (upTo) { + cardsToDraw = player.getAmount(0, cardsToDraw, "Draw how many cards?", game); + } if (!optional || player.chooseUse(outcome, "Use draw effect?", game)) { - player.drawCards(amount.calculate(game, source), game); + player.drawCards(cardsToDraw, game); } return true; } @@ -88,6 +100,9 @@ public class DrawCardTargetEffect extends OneShotEffect { @Override public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } StringBuilder sb = new StringBuilder(); if (mode.getTargets().size() > 0) { sb.append("Target ").append(mode.getTargets().get(0).getTargetName()); @@ -99,6 +114,9 @@ public class DrawCardTargetEffect extends OneShotEffect { } else { sb.append(" draws "); } + if (upTo) { + sb.append("up to "); + } sb.append(CardUtil.numberToText(amount.toString())).append(" card"); try { if (Integer.parseInt(amount.toString()) > 1) {