From e68c37432bdec351a7cb764c7eefb205953dbdec Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 7 Feb 2019 14:35:00 -0600 Subject: [PATCH] - Fixed #5577 --- .../src/mage/cards/r/RestlessDreams.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Mage.Sets/src/mage/cards/r/RestlessDreams.java b/Mage.Sets/src/mage/cards/r/RestlessDreams.java index d20f30be5e..a2b83827f3 100644 --- a/Mage.Sets/src/mage/cards/r/RestlessDreams.java +++ b/Mage.Sets/src/mage/cards/r/RestlessDreams.java @@ -1,4 +1,3 @@ - package mage.cards.r; import mage.abilities.Ability; @@ -14,6 +13,9 @@ import mage.target.common.TargetCardInYourGraveyard; import mage.target.targetadjustment.TargetAdjuster; import java.util.UUID; +import mage.abilities.costs.Cost; +import mage.filter.common.FilterCreatureCard; +import mage.target.Target; /** * @author fireshoes @@ -29,6 +31,8 @@ public final class RestlessDreams extends CardImpl { Effect effect = new ReturnFromGraveyardToHandTargetEffect(); effect.setText("Return X target creature cards from your graveyard to your hand"); this.getSpellAbility().addEffect(effect); + this.getSpellAbility().setTargetAdjuster(RestlessDreamsAdjuster.instance); + } public RestlessDreams(final RestlessDreams card) { @@ -47,9 +51,15 @@ enum RestlessDreamsAdjuster implements TargetAdjuster { @Override public void adjustTargets(Ability ability, Game game) { ability.getTargets().clear(); - ability.addTarget(new TargetCardInYourGraveyard( - ability.getManaCostsToPay().getX(), - StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD - )); + int xValue = 0; + for (Cost cost : ability.getCosts()) { + if (cost instanceof DiscardXTargetCost) { + xValue = ((DiscardXTargetCost) cost).getAmount(); + } + } + Target target = new TargetCardInYourGraveyard(xValue, + new FilterCreatureCard(new StringBuilder(xValue).append(xValue != 1 ? + " creature cards" : "creature card").append(" from your graveyard").toString())); + ability.addTarget(target); } -} \ No newline at end of file +}