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.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
@ -62,7 +63,6 @@ import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author jeffwadsworth
*/
public class ChandraPyromaster extends CardImpl {
@ -211,10 +211,12 @@ class ChandraPyromasterEffect2 extends OneShotEffect {
Card card = library.removeFromTop(game);
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);
if (!card.getManaCost().isEmpty()) {
ContinuousEffect effect = new ChandraPyromasterCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
}
return true;
}
return false;

View file

@ -117,9 +117,10 @@ class ChandraTorchOfDefianceEffect extends OneShotEffect {
if (controller != null && sourceObject != null && controller.getLibrary().size() > 0) {
Library library = controller.getLibrary();
Card card = library.removeFromTop(game);
if (card != null && !card.getManaCost().isEmpty()) {
if (card != null) {
boolean exiledCardWasCast = false;
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true);
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);
// for (ActivatedAbility ability : useableAbilities.values()) {
@ -131,6 +132,7 @@ class ChandraTorchOfDefianceEffect extends OneShotEffect {
if (!exiledCardWasCast) {
new DamagePlayersEffect(Outcome.Damage, new StaticValue(2), TargetController.OPPONENT).apply(game, source);
}
}
return true;
}

View file

@ -44,6 +44,29 @@ public class ChandraPyromasterTest extends CardTestPlayerBase {
}
@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
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 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.
*