[GRN] Fix Wand of Vertebrae not working properly. Closes #9464

This commit is contained in:
Alex Vasile 2022-09-04 20:35:19 -04:00
parent fef04007d4
commit 9c59ec698d
2 changed files with 45 additions and 41 deletions

View file

@ -8,6 +8,7 @@ import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.MillCardsControllerEffect;
import mage.abilities.effects.common.ShuffleIntoLibraryTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -35,10 +36,7 @@ public final class WandOfVertebrae extends CardImpl {
));
// {2}, {T}, Exile Wand of Vertebrae: Shuffle up to five target cards from your graveyard into your library.
Ability ability = new SimpleActivatedAbility(
new WandOfVertebraeEffect(),
new GenericManaCost(2)
);
Ability ability = new SimpleActivatedAbility(new ShuffleIntoLibraryTargetEffect(), new GenericManaCost(2));
ability.addCost(new TapSourceCost());
ability.addCost(new ExileSourceCost());
ability.addTarget(new TargetCardInYourGraveyard(0, 5));
@ -53,40 +51,4 @@ public final class WandOfVertebrae extends CardImpl {
public WandOfVertebrae copy() {
return new WandOfVertebrae(this);
}
}
class WandOfVertebraeEffect extends OneShotEffect {
public WandOfVertebraeEffect() {
super(Outcome.Benefit);
this.staticText = "Shuffle up to five target cards "
+ "from your graveyard into your library.";
}
public WandOfVertebraeEffect(final WandOfVertebraeEffect effect) {
super(effect);
}
@Override
public WandOfVertebraeEffect copy() {
return new WandOfVertebraeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl();
for (UUID targetId : targetPointer.getTargets(game, source)) {
Card card = game.getCard(targetId);
if (card != null) {
cards.add(card);
}
}
player.getLibrary().addAll(cards.getCards(game), game);
player.shuffleLibrary(source, game);
return true;
}
}
}

View file

@ -0,0 +1,42 @@
package org.mage.test.cards.single.grn;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* {T}: Mill a card.
* {2}, {T}, Exile Wand of Vertebrae: Shuffle up to five target cards from your graveyard into your library.
*
* @author Alex-Vasile
*/
public class WandOfVertebraeTest extends CardTestPlayerBase {
private static final String wandOfVertebrae = "Wand of Vertebrae";
/**
* Reported bug: https://github.com/magefree/mage/issues/9464
*
*/
@Test
public void canChoosePreviouslyBuggedCard() {
String lavaCoil = "Lava Coil";
addCard(Zone.BATTLEFIELD, playerA, wandOfVertebrae);
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
addCard(Zone.GRAVEYARD, playerA, lavaCoil);
setStrictChooseMode(true);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}, {T}");
addTarget(playerA, lavaCoil);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertExileCount(playerA, wandOfVertebrae, 1);
assertGraveyardCount(playerA, lavaCoil, 0);
assertLibraryCount(playerA, lavaCoil, 1);
}
}