Fix that Warbringer's cost reduction doesn't apply when checking playable (for real this time)

This commit is contained in:
Alex W. Jackson 2022-04-03 10:19:22 -04:00
parent 081b2f2f39
commit c58eeef77d
3 changed files with 26 additions and 3 deletions

View file

@ -9,6 +9,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.common.DashedCondition;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.DashAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
@ -69,8 +70,14 @@ class WarbringerSpellsCostReductionEffect extends CostModificationEffectImpl {
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) {
if (abilityToModify.isControlledBy(source.getControllerId())) {
if (abilityToModify instanceof SpellAbility
&& abilityToModify.isControlledBy(source.getControllerId())) {
if (game != null && game.inCheckPlayableState()) {
Card card = game.getCard(source.getSourceId());
if (card != null) {
return card.getAbilities(game).stream().anyMatch(a -> a instanceof DashAbility);
}
} else {
return DashedCondition.instance.apply(game, abilityToModify);
}
}

View file

@ -117,4 +117,20 @@ public class DashTest extends CardTestPlayerBase {
assertHandCount(playerA, "Screamreach Brawler", 0);
assertAbility(playerA, "Screamreach Brawler", HasteAbility.getInstance(), true);
}
@Test
public void testWarbringerCostReduction() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
addCard(Zone.BATTLEFIELD, playerA, "Warbringer");
addCard(Zone.HAND, playerA, "Warbringer");
setStrictChooseMode(true);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Warbringer");
setChoice(playerA, true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Warbringer", 2);
assertHandCount(playerA, "Warbringer", 0);
}
}