* Cavern of Souls - Fixed that conditional mana in the mana pool remembers correctly for which creature subtrype its usable.

This commit is contained in:
LevelX2 2014-08-29 14:48:04 +02:00
parent 35d3c14dc6
commit 1f196f0bc7
11 changed files with 133 additions and 36 deletions

View file

@ -136,4 +136,54 @@ public class CavernOfSoulsTest extends CardTestPlayerBase {
assertGraveyardCount(playerA, "Azure Drake", 1);
assertPermanentCount(playerA, "Azure Drake", 0);
}
/**
* Tests conditional mana from Cavern in pool will still work if Cavern got back to hand and is played again with other creature type
*/
@Test
public void testConditionlManaWorksIfCavernIsReplayed() {
addCard(Zone.HAND, playerA, "Cavern of Souls");
addCard(Zone.HAND, playerA, "Gladecover Scout"); // Elf costing {G}
// addCard(Zone.HAND, playerA, "Fume Spitter"); // Horror costing {B}
// Instant - {U}{U} - Return target permanent to its owner's hand.
addCard(Zone.HAND, playerB, "Boomerang");
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cavern of Souls");
setChoice(playerA, "Elf");
// getting green mana for Elf into pool
activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add 1 mana of any one color to your mana pool. Spend this mana only to cast a creature spell of the chosen type, and that spell can't be countered.");
setChoice(playerA, "Green");
// return cavern to hand
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerB, "Boomerang", "Cavern of Souls");
// playing the cavern again choose different creature type
playLand(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cavern of Souls");
setChoice(playerA, "Horror");
// the green mana usable for Elf should be in the mana pool
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Gladecover Scout");
activateManaAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add 1 mana of any one color to your mana pool. Spend this mana only to cast a creature spell of the chosen type, and that spell can't be countered.");
setChoice(playerA, "Black");
// the black mana usable for Horror should be in the mana pool
// castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Fume Spitter");
setStopAt(3, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, "Boomerang", 1);
assertPermanentCount(playerA, "Cavern of Souls", 1);
// Check the elf was cast
assertPermanentCount(playerA, "Gladecover Scout", 1);
// Check Horror on the Battlefield
// assertPermanentCount(playerA, "Fume Spitter", 1);
}
}

View file

@ -62,6 +62,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import mage.abilities.mana.ManaAbility;
import mage.constants.Zone;
/**
*
@ -114,6 +116,7 @@ public class TestPlayer extends ComputerPlayer {
public boolean priority(Game game) {
for (PlayerAction action: actions) {
if (action.getTurnNum() == game.getTurnNum() && action.getStep() == game.getStep().getType()) {
if (action.getAction().startsWith("activate:")) {
String command = action.getAction();
command = command.substring(command.indexOf("activate:") + 9);
@ -135,7 +138,26 @@ public class TestPlayer extends ComputerPlayer {
return true;
}
}
}
} else
if (action.getAction().startsWith("manaActivate:")) {
String command = action.getAction();
command = command.substring(command.indexOf("manaActivate:") + 13);
String[] groups = command.split(";");
List<Permanent> manaPerms = this.getAvailableManaProducers(game);
for (Permanent perm: manaPerms) {
for (Ability manaAbility: perm.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
if (manaAbility.toString().startsWith(groups[0])) {
Ability newManaAbility = manaAbility.copy();
this.activateAbility((ActivatedAbility)newManaAbility, game);
actions.remove(action);
return true;
}
}
}
} else
if (action.getAction().startsWith("addCounters:")) {
String command = action.getAction();
command = command.substring(command.indexOf("addCounters:") + 12);

View file

@ -734,6 +734,10 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
player.addAction(turnNum, step, action);
}
public void activateManaAbility(int turnNum, PhaseStep step, TestPlayer player, String ability) {
player.addAction(turnNum, step, "manaActivate:" + ability);
}
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability) {
player.addAction(turnNum, step, "activate:" + ability);
}

View file

@ -7,7 +7,6 @@ import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Rarity;
import mage.interfaces.rate.RateCallback;
import mage.sets.guru.Island;
import mage.utils.DeckBuilder;
import org.junit.Assert;
import org.junit.Test;
@ -16,6 +15,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import mage.sets.unhinged.Island;
/**
* @author dustinconrad