the card should still be exiled.

added a method to test exile count per player
added a test for chandrapyromaster
This commit is contained in:
ingmargoudt 2017-02-19 09:09:43 +01:00
parent d729ab31d2
commit 9ea690797f
4 changed files with 55 additions and 9 deletions

View file

@ -30,6 +30,7 @@ package mage.cards.c;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
@ -62,13 +63,12 @@ import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
/** /**
*
* @author jeffwadsworth * @author jeffwadsworth
*/ */
public class ChandraPyromaster extends CardImpl { public class ChandraPyromaster extends CardImpl {
public ChandraPyromaster(UUID ownerId, CardSetInfo setInfo) { public ChandraPyromaster(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.PLANESWALKER},"{2}{R}{R}"); super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{R}{R}");
this.subtype.add("Chandra"); this.subtype.add("Chandra");
this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(4)); this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(4));
@ -211,9 +211,11 @@ class ChandraPyromasterEffect2 extends OneShotEffect {
Card card = library.removeFromTop(game); Card card = library.removeFromTop(game);
if (card != null) { if (card != null) {
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName() + " <this card may be played the turn it was exiled>", source.getSourceId(), game, Zone.LIBRARY, true); controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName() + " <this card may be played the turn it was exiled>", source.getSourceId(), game, Zone.LIBRARY, true);
ContinuousEffect effect = new ChandraPyromasterCastFromExileEffect(); if (!card.getManaCost().isEmpty()) {
effect.setTargetPointer(new FixedTarget(card.getId())); ContinuousEffect effect = new ChandraPyromasterCastFromExileEffect();
game.addEffect(effect, source); effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
} }
return true; return true;
} }

View file

@ -117,20 +117,22 @@ class ChandraTorchOfDefianceEffect extends OneShotEffect {
if (controller != null && sourceObject != null && controller.getLibrary().size() > 0) { if (controller != null && sourceObject != null && controller.getLibrary().size() > 0) {
Library library = controller.getLibrary(); Library library = controller.getLibrary();
Card card = library.removeFromTop(game); Card card = library.removeFromTop(game);
if (card != null && !card.getManaCost().isEmpty()) { if (card != null) {
boolean exiledCardWasCast = false; boolean exiledCardWasCast = false;
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true); controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
if (controller.chooseUse(Outcome.Benefit, "Cast the card? (You still pay the costs)", source, game) && !card.getCardType().contains(CardType.LAND)) { if (!card.getManaCost().isEmpty())
if (controller.chooseUse(Outcome.Benefit, "Cast the card? (You still pay the costs)", source, game) && !card.getCardType().contains(CardType.LAND)) {
// LinkedHashMap<UUID, ActivatedAbility> useableAbilities = controller.getUseableActivatedAbilities(card, Zone.EXILED, game); // LinkedHashMap<UUID, ActivatedAbility> useableAbilities = controller.getUseableActivatedAbilities(card, Zone.EXILED, game);
// for (ActivatedAbility ability : useableAbilities.values()) { // for (ActivatedAbility ability : useableAbilities.values()) {
// //
// } // }
// controller.activateAbility(useableAbilities, game); // controller.activateAbility(useableAbilities, game);
exiledCardWasCast = controller.cast(card.getSpellAbility(), game, false); exiledCardWasCast = controller.cast(card.getSpellAbility(), game, false);
} }
if (!exiledCardWasCast) { if (!exiledCardWasCast) {
new DamagePlayersEffect(Outcome.Damage, new StaticValue(2), TargetController.OPPONENT).apply(game, source); new DamagePlayersEffect(Outcome.Damage, new StaticValue(2), TargetController.OPPONENT).apply(game, source);
} }
} }
return true; return true;
} }

View file

@ -43,6 +43,29 @@ public class ChandraPyromasterTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Silvercoat Lion", 1); assertGraveyardCount(playerB, "Silvercoat Lion", 1);
} }
@Test
public void testAbility2AncestralVision() {
addCard(Zone.BATTLEFIELD, playerA, "Chandra, Pyromaster");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
skipInitShuffling();
addCard(Zone.LIBRARY, playerA, "Ancestral Vision");
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+0: Exile the top card of your library. You may play it this turn.");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Chandra, Pyromaster", 1);
assertGraveyardCount(playerA, "Ancestral Vision", 0);
assertExileCount(playerA, "Ancestral Vision", 1);
}
@Test @Test
public void testAbility2CastCardFromExileWithOverlaod() { public void testAbility2CastCardFromExileWithOverlaod() {

View file

@ -860,6 +860,25 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertEquals("(Exile) Card counts for player " + owner.getName() + " is not equal.", count, actualCount); Assert.assertEquals("(Exile) Card counts for player " + owner.getName() + " is not equal.", count, actualCount);
} }
/**
* Assert card count in player's graveyard.
*
* @param owner {@link Player} who's graveyard should be counted.
* @param cardName Name of the cards that should be counted.
* @param count Expected count.
*/
public void assertExileCount(Player owner, String cardName, int count) throws AssertionError {
int actualCount = 0;
for (ExileZone exile : currentGame.getExile().getExileZones()) {
for (Card card : exile.getCards(currentGame)) {
if (card.getOwnerId().equals(owner.getId()) && card.getName().equals(cardName)) {
actualCount++;
}
}
}
Assert.assertEquals("(Exile " + owner.getName() + ") Card counts are not equal (" + cardName + ')', count, actualCount);
}
/** /**
* Assert card count in player's graveyard. * Assert card count in player's graveyard.
* *