Avacyn test for reported bug. Creeping Dread efficiency improvements

This commit is contained in:
drmDev 2016-04-02 08:16:47 -04:00
parent b3e8f80883
commit e7b80d9548
2 changed files with 68 additions and 12 deletions

View file

@ -27,10 +27,10 @@
*/ */
package mage.sets.shadowsoverinnistrad; package mage.sets.shadowsoverinnistrad;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -102,7 +102,7 @@ class CreepingDreadEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
List<CardType> typesChosen = new ArrayList<>(); Set<CardType> typesChosen = new HashSet<>();
Map<Player,Card> cardsChosen = new HashMap<>(); Map<Player,Card> cardsChosen = new HashMap<>();
if(!controller.getHand().isEmpty()) { if(!controller.getHand().isEmpty()) {
@ -110,13 +110,13 @@ class CreepingDreadEffect extends OneShotEffect {
if(controller.choose(Outcome.Discard, controller.getHand(), controllerTarget, game)) { if(controller.choose(Outcome.Discard, controller.getHand(), controllerTarget, game)) {
Card card = controller.getHand().get(controllerTarget.getFirstTarget(), game); Card card = controller.getHand().get(controllerTarget.getFirstTarget(), game);
if (card != null) { if (card != null) {
typesChosen = card.getCardType(); typesChosen = new HashSet<>(card.getCardType());
cardsChosen.put(controller, card); cardsChosen.put(controller, card);
} }
} }
} }
ArrayList<Player> opponentsAffected = new ArrayList<>(); Set<Player> opponentsAffected = new HashSet<>();
for (UUID playerId : game.getOpponents(source.getControllerId())) { for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(playerId); Player opponent = game.getPlayer(playerId);
// opponent discards a card - if it is same card type as controller, add to opponentsAffected // opponent discards a card - if it is same card type as controller, add to opponentsAffected
@ -141,13 +141,6 @@ class CreepingDreadEffect extends OneShotEffect {
} }
} }
} }
// each opponent who discarded a card of the same type loses 3 life
if (!opponentsAffected.isEmpty()) {
for(Player opponent : opponentsAffected) {
opponent.loseLife(3, game);
}
}
// everyone discards the card at the same time // everyone discards the card at the same time
if (!cardsChosen.isEmpty()) { if (!cardsChosen.isEmpty()) {
@ -158,6 +151,13 @@ class CreepingDreadEffect extends OneShotEffect {
player.discard(cardChosen, source, game); player.discard(cardChosen, source, game);
} }
} }
}
// each opponent who discarded a card of the same type loses 3 life
if (!opponentsAffected.isEmpty()) {
for(Player opponent : opponentsAffected) {
opponent.loseLife(3, game);
}
} }
return true; return true;

View file

@ -0,0 +1,56 @@
package org.mage.test.cards.single.soi;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* {3}{W}{W} Angel - day
*
Flash
Flying, vigilance
When Archangel Avacyn enters the battlefield, creatures you control gain indestructible until end of turn.
* When a non-Angel creature you control dies, transform Archangel Avacyn at the beginning of the next upkeep.
*
* (Night) - red card
* When this creature transforms into Avacyn, the Purifier, it deals 3 damage to each other creature and each opponent.
*
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
*/
public class ArchangelAvacynTest extends CardTestPlayerBase {
/**
* Reported bug: "Archangel Avacyn damages herself when she transforms"
*/
@Test
public void basicTransformTest() {
addCard(Zone.BATTLEFIELD, playerA, "Archangel Avacyn");
addCard(Zone.BATTLEFIELD, playerA, "Wall of Omens"); // 0/4
addCard(Zone.HAND, playerA, "Elite Vanguard"); // 2/1
addCard(Zone.BATTLEFIELD, playerA, "Plains", 2);
addCard(Zone.BATTLEFIELD, playerB, "Hill Giant"); // 3/1
addCard(Zone.BATTLEFIELD, playerB, "Wall of Roots"); // 0/5
addCard(Zone.HAND, playerB, "Shock");
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Vanguard");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Shock");
addTarget(playerB, "Elite Vanguard");
setStopAt(3, PhaseStep.DRAW);
execute();
assertPermanentCount(playerA, "Avacyn, the Purifier", 1);
assertPermanentCount(playerA, "Wall of Omens", 1);
assertGraveyardCount(playerA, "Elite Vanguard", 1);
assertPermanentCount(playerB, "Wall of Roots", 1);
assertGraveyardCount(playerB, "Hill Giant", 1);
assertGraveyardCount(playerB, "Shock", 1);
Permanent avacyn = getPermanent("Avacyn, the Purifier", playerA);
Assert.assertEquals("Damage to Avacyn, the Purifier should be 0 not 3", 0, avacyn.getDamage());
}
}