mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
Added a test for conditional mana.
This commit is contained in:
parent
7453d6a39e
commit
54be23cb41
2 changed files with 80 additions and 9 deletions
|
|
@ -54,7 +54,7 @@ public class PillarOfTheParuns extends CardImpl {
|
||||||
super(ownerId, 176, "Pillar of the Paruns", Rarity.RARE, new CardType[]{CardType.LAND}, "");
|
super(ownerId, 176, "Pillar of the Paruns", Rarity.RARE, new CardType[]{CardType.LAND}, "");
|
||||||
this.expansionSetCode = "DIS";
|
this.expansionSetCode = "DIS";
|
||||||
|
|
||||||
// {tap}: Add one mana of any color to your mana pool. Spend this mana only to cast a multicolored spell.
|
// {T}: Add one mana of any color to your mana pool. Spend this mana only to cast a multicolored spell.
|
||||||
this.addAbility(new ConditionalAnyColorManaAbility(1, new PillarOfTheParunsManaBuilder()));
|
this.addAbility(new ConditionalAnyColorManaAbility(1, new PillarOfTheParunsManaBuilder()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,17 +92,11 @@ class PillarOfTheParunsConditionalMana extends ConditionalMana {
|
||||||
|
|
||||||
class MultiColoredSpellCastManaCondition extends ManaCondition implements Condition {
|
class MultiColoredSpellCastManaCondition extends ManaCondition implements Condition {
|
||||||
|
|
||||||
private static final MulticoloredPredicate multicolored = new MulticoloredPredicate();
|
|
||||||
|
|
||||||
private static class LazyHolder {
|
|
||||||
private static final MulticoloredPredicate multicolored = new MulticoloredPredicate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
if (source instanceof SpellAbility) {
|
if (source instanceof SpellAbility) {
|
||||||
MageObject object = game.getObject(source.getSourceId());
|
MageObject object = game.getObject(source.getSourceId());
|
||||||
if (object != null && LazyHolder.multicolored.apply(object, game)) {
|
if (object != null && object.getColor().getColorCount() > 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package org.mage.test.cards.mana;
|
||||||
|
|
||||||
|
import mage.constants.PhaseStep;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ConditionalManaTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNormalUse() {
|
||||||
|
// {T}: Add one mana of any color to your mana pool. Spend this mana only to cast a multicolored spell.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Pillar of the Paruns", 2);
|
||||||
|
// Instant {G}{W}
|
||||||
|
// Target player gains 7 life.
|
||||||
|
addCard(Zone.HAND, playerA, "Heroes' Reunion", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Heroes' Reunion", playerA);
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertGraveyardCount(playerA, "Heroes' Reunion", 1);
|
||||||
|
assertHandCount(playerA, "Heroes' Reunion", 0); // player A could not cast it
|
||||||
|
assertLife(playerA, 27);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotAllowedUse() {
|
||||||
|
// {T}: Add one mana of any color to your mana pool. Spend this mana only to cast a multicolored spell.
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Pillar of the Paruns", 2);
|
||||||
|
addCard(Zone.HAND, playerA, "Silvercoat Lion", 1);
|
||||||
|
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
|
||||||
|
playerA.addChoice("White");
|
||||||
|
playerA.addChoice("White");
|
||||||
|
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
|
execute();
|
||||||
|
|
||||||
|
assertHandCount(playerA, "Silvercoat Lion", 1); // player A could not cast Silvercoat Lion because the conditional mana is not available
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue