the sacrifice target cost was optional, but SacrificeCost.canPay first checks if there are valid targets. In this scenario there were none, but the spell should still be playable
This commit is contained in:
Ingmar Goudt 2021-08-22 12:01:10 +02:00
parent 6c837e733b
commit 271f7b812f
2 changed files with 21 additions and 0 deletions

View file

@ -190,4 +190,21 @@ public class OptionalSacrificeTests extends CardTestPlayerBase {
assertHandCount(playerB, "Propaganda", 0);
assertPermanentCount(playerB, "Propaganda", 1);
}
/**
As an additional cost to cast Devouring Greed, you may sacrifice any number of Spirits.
// Target player loses 2 life plus 2 life for each Spirit sacrificed this way. You gain that much life.
**/
@Test
public void testDevouringGreedWithoutSpirits(){
addCard(Zone.HAND, playerA, "Devouring Greed");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 10);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Devouring Greed", playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerB, 18);
assertLife(playerA, 22);
assertGraveyardCount(playerA, "Devouring Greed", 1);
}
}

View file

@ -87,6 +87,10 @@ public class SacrificeTargetCost extends CostImpl {
}
}
}
// solves issue #8097, if a sacrifice cost is optional and you don't have valid targets, then the cost can be paid
if(validTargets == 0 && targets.get(0).getMinNumberOfTargets() == 0){
return true;
}
return false;
}