Fix a bug with Animar's cost reduction effect.

This commit is contained in:
dilnu 2018-07-29 11:19:51 -04:00
parent 339779c8bd
commit 988b64866c
2 changed files with 32 additions and 1 deletions

View file

@ -11,6 +11,7 @@ import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -85,7 +86,7 @@ class AnimarCostReductionEffect extends CostModificationEffectImpl {
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) {
if (abilityToModify.isControlledBy(source.getControllerId())) {
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
Card spell = ((SpellAbility) abilityToModify).getCharachteristics(game);
if (spell != null) {
return spell.isCreature();
}

View file

@ -217,4 +217,34 @@ public class CostModificationTest extends CardTestPlayerBase {
assertTappedCount("Plains", false, 2); // 2 for 1st Lion 1 for 2nd lion and only 1 mana needed to cast face down Zoetic
}
/**
* Zoetic Cavern's cast as creature cost is not modified as Animar, Soul of
* Elements gains counters.
*/
@Test
public void AnimarSoulOfElementsTest() {
// Protection from white and from black
// Whenever you cast a creature spell, put a +1/+1 counter on Animar, Soul of Elements.
// Creature spells you cast cost {1} less to cast for each +1/+1 counter on Animar.
addCard(Zone.BATTLEFIELD, playerA, "Animar, Soul of Elements");
addCard(Zone.HAND, playerA, "Silvercoat Lion", 2);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
addCard(Zone.HAND, playerA, "Zoetic Cavern");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, "Silvercoat Lion", 2);
assertCounterCount(playerA, "Animar, Soul of Elements", CounterType.P1P1, 2);
assertTappedCount("Plains", true, 3);
}
}