* Fixed bug of Druids Repository (related to b5c93cf2da),

This commit is contained in:
LevelX2 2020-07-28 13:28:24 +02:00
parent 7e771a2fc3
commit 0458778c44
4 changed files with 149 additions and 83 deletions

View file

@ -31,10 +31,9 @@ public final class DruidsRepository extends CardImpl {
this.addAbility(new AttacksCreatureYouControlTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance()))); this.addAbility(new AttacksCreatureYouControlTriggeredAbility(new AddCountersSourceEffect(CounterType.CHARGE.createInstance())));
// Remove a charge counter from Druids' Repository: Add one mana of any color. // Remove a charge counter from Druids' Repository: Add one mana of any color.
Ability ability = new SimpleManaAbility(Zone.BATTLEFIELD, Mana.AnyMana(1), this.addAbility(new SimpleManaAbility(Zone.BATTLEFIELD,
new RemoveCountersSourceCost(CounterType.CHARGE.createInstance()), new AddManaOfAnyColorEffect(1, new CountersSourceCount(CounterType.CHARGE), false),
new CountersSourceCount(CounterType.CHARGE)); new RemoveCountersSourceCost(CounterType.CHARGE.createInstance())));
this.addAbility(ability);
} }
public DruidsRepository(final DruidsRepository card) { public DruidsRepository(final DruidsRepository card) {

View file

@ -0,0 +1,130 @@
package org.mage.test.cards.mana;
import mage.abilities.mana.ManaOptions;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions;
/**
*
* @author LevelX2
*/
public class NonTappingManaAbilitiesTest extends CardTestPlayerBase {
@Test
public void druidsRepositoryTest() {
setStrictChooseMode(true);
addCard(Zone.HAND, playerA, "Alaborn Grenadier", 1); //Creature {W}{W}
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 2);
// Whenever a creature you control attacks, put a charge counter on Druids' Repository.
// Remove a charge counter from Druids' Repository: Add one mana of any color.
addCard(Zone.BATTLEFIELD, playerA, "Druids' Repository", 1); // Enchantment {1}{G}{G}
attack(1, playerA, "Silvercoat Lion");
attack(1, playerA, "Silvercoat Lion");
setChoice(playerA, "Whenever a creature you control");
setStopAt(1, PhaseStep.END_COMBAT);
execute();
assertTappedCount("Silvercoat Lion", true, 2);
assertCounterCount(playerA,"Druids' Repository", CounterType.CHARGE, 2);
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{Any}{Any}", manaOptions);
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Alaborn Grenadier");
setChoice(playerA, "White");
setChoice(playerA, "White");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertCounterCount(playerA,"Druids' Repository", CounterType.CHARGE, 0);
assertPermanentCount(playerA, "Alaborn Grenadier", 1);
}
@Test
public void TestWorkhorse() {
setStrictChooseMode(true);
// Workhorse enters the battlefield with four +1/+1 counters on it.
// Remove a +1/+1 counter from Workhorse: Add {C}.
addCard(Zone.BATTLEFIELD, playerA, "Workhorse", 1);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{C}{C}{C}{C}", manaOptions);
}
@Test
public void TestMorselhoarder() {
setStrictChooseMode(true);
// Morselhoarder enters the battlefield with two -1/-1 counters on it.
// Remove a -1/-1 counter from Morselhoarder: Add one mana of any color.
addCard(Zone.BATTLEFIELD, playerA, "Morselhoarder", 2);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{B}{B}{Any}{Any}{Any}{Any}", manaOptions);
}
@Test
public void TestFarrelitePriest() {
setStrictChooseMode(true);
// {1}: Add {W}. If this ability has been activated four or more times this turn, sacrifice Farrelite Priest at the beginning of the next end step.
addCard(Zone.BATTLEFIELD, playerA, "Farrelite Priest", 1);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 5, manaOptions.size());
assertManaOptions("{W}{W}{W}{W}", manaOptions);
assertManaOptions("{W}{W}{W}{B}", manaOptions);
assertManaOptions("{W}{W}{B}{B}", manaOptions);
assertManaOptions("{W}{B}{B}{B}", manaOptions);
assertManaOptions("{B}{B}{B}{B}", manaOptions);
}
@Test
public void TestCrystallineCrawler() {
setStrictChooseMode(true);
// Converge - Crystalline Crawler enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it.
// Remove a +1/+1 counter from Crystalline Crawler: Add one mana of any color.
// {T}: Put a +1/+1 counter on Crystalline Crawler.
addCard(Zone.BATTLEFIELD, playerA, "Crystalline Crawler", 1);
addCounters(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Crystalline Crawler", CounterType.P1P1, 2);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{Any}{Any}", manaOptions);
}
}

View file

@ -201,24 +201,7 @@ public class TappedForManaRelatedTest extends CardTestPlayerBase {
assertManaOptions("{R}", manaOptions); assertManaOptions("{R}", manaOptions);
} }
@Test
public void TestCrystallineCrawler() {
setStrictChooseMode(true);
// Converge - Crystalline Crawler enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it.
// Remove a +1/+1 counter from Crystalline Crawler: Add one mana of any color.
// {T}: Put a +1/+1 counter on Crystalline Crawler.
addCard(Zone.BATTLEFIELD, playerA, "Crystalline Crawler", 1);
addCounters(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Crystalline Crawler", CounterType.P1P1, 2);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{Any}{Any}", manaOptions);
}
@Test @Test
@Ignore // Because this is no mana ability, this mana will not be calculated during available mana calculation @Ignore // Because this is no mana ability, this mana will not be calculated during available mana calculation
@ -258,44 +241,7 @@ public class TappedForManaRelatedTest extends CardTestPlayerBase {
assertManaOptions("{U}{U}{U}{U}", manaOptions); assertManaOptions("{U}{U}{U}{U}", manaOptions);
} }
@Test
public void TestFarrelitePriest() {
setStrictChooseMode(true);
// {1}: Add {W}. If this ability has been activated four or more times this turn, sacrifice Farrelite Priest at the beginning of the next end step.
addCard(Zone.BATTLEFIELD, playerA, "Farrelite Priest", 1);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 5, manaOptions.size());
assertManaOptions("{W}{W}{W}{W}", manaOptions);
assertManaOptions("{W}{W}{W}{B}", manaOptions);
assertManaOptions("{W}{W}{B}{B}", manaOptions);
assertManaOptions("{W}{B}{B}{B}", manaOptions);
assertManaOptions("{B}{B}{B}{B}", manaOptions);
}
@Test
public void TestMorselhoarder() {
setStrictChooseMode(true);
// Morselhoarder enters the battlefield with two -1/-1 counters on it.
// Remove a -1/-1 counter from Morselhoarder: Add one mana of any color.
addCard(Zone.BATTLEFIELD, playerA, "Morselhoarder", 2);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{B}{B}{Any}{Any}{Any}{Any}", manaOptions);
}
@Test @Test
public void TestChromaticOrrery() { public void TestChromaticOrrery() {
@ -343,21 +289,5 @@ public class TappedForManaRelatedTest extends CardTestPlayerBase {
assertManaOptions("{G}{G}{G}{G}{G}{G}{G}", manaOptions); assertManaOptions("{G}{G}{G}{G}{G}{G}{G}", manaOptions);
} }
@Test
public void TestWorkhorse() {
setStrictChooseMode(true);
// Workhorse enters the battlefield with four +1/+1 counters on it.
// Remove a +1/+1 counter from Workhorse: Add {C}.
addCard(Zone.BATTLEFIELD, playerA, "Workhorse", 1);
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{C}{C}{C}{C}", manaOptions);
}
} }

View file

@ -49,19 +49,26 @@ public class BasicManaEffect extends ManaEffect {
Mana computedMana = new Mana(); Mana computedMana = new Mana();
if (manaTemplate.getBlack() > 0) { if (manaTemplate.getBlack() > 0) {
computedMana.setBlack(count * manaTemplate.getBlack()); computedMana.setBlack(count * manaTemplate.getBlack());
} else if (manaTemplate.getBlue() > 0) { }
if (manaTemplate.getBlue() > 0) {
computedMana.setBlue(count * manaTemplate.getBlue()); computedMana.setBlue(count * manaTemplate.getBlue());
} else if (manaTemplate.getGreen() > 0) { }
if (manaTemplate.getGreen() > 0) {
computedMana.setGreen(count * manaTemplate.getGreen()); computedMana.setGreen(count * manaTemplate.getGreen());
} else if (manaTemplate.getRed() > 0) { }
if (manaTemplate.getRed() > 0) {
computedMana.setRed(count * manaTemplate.getRed()); computedMana.setRed(count * manaTemplate.getRed());
} else if (manaTemplate.getWhite() > 0) { }
if (manaTemplate.getWhite() > 0) {
computedMana.setWhite(count * manaTemplate.getWhite()); computedMana.setWhite(count * manaTemplate.getWhite());
} else if (manaTemplate.getColorless() > 0) { }
if (manaTemplate.getColorless() > 0) {
computedMana.setColorless(count * manaTemplate.getColorless()); computedMana.setColorless(count * manaTemplate.getColorless());
} else if (manaTemplate.getAny() > 0) { }
computedMana.setAny(count * manaTemplate.getAny()); if (manaTemplate.getAny() > 0) {
} else if (manaTemplate.getGeneric() > 0){ throw new IllegalArgumentException("BasicManaEffect does not support {Any} mana!");
}
if (manaTemplate.getGeneric() > 0) {
computedMana.setGeneric(count * manaTemplate.getGeneric()); computedMana.setGeneric(count * manaTemplate.getGeneric());
} }
return new ArrayList<>(Arrays.asList(computedMana)); return new ArrayList<>(Arrays.asList(computedMana));