Fix DoIfCostPaid effect when it is not optional.

This commit is contained in:
Quercitron 2016-05-02 16:06:56 +03:00
parent 0495c5a17a
commit 596e2f7f19
2 changed files with 33 additions and 1 deletions

View file

@ -0,0 +1,32 @@
package org.mage.test.cards.conditional;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author Quercitron
*/
public class DoIfCostPaidTest extends CardTestPlayerBase {
@Test
public void testPayIsNotOptional() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
// Shock deals 2 damage to target creature or player.
addCard(Zone.HAND, playerA, "Shock", 1);
// When a source an opponent controls deals damage to you, sacrifice Awaken the Sky Tyrant.
// If you do, put a 5/5 red Dragon creature token with flying onto the battlefield.
addCard(Zone.BATTLEFIELD, playerB, "Awaken the Sky Tyrant");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Shock", playerB);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerB, "Awaken the Sky Tyrant", 0);
assertPermanentCount(playerB, "Dragon", 1);
}
}

View file

@ -67,7 +67,7 @@ public class DoIfCostPaid extends OneShotEffect {
message = CardUtil.replaceSourceName(message, mageObject.getLogName());
boolean result = true;
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
&& (optional && player.chooseUse(executingEffects.get(0).getOutcome(), message, source, game))) {
&& (!optional || player.chooseUse(executingEffects.get(0).getOutcome(), message, source, game))) {
cost.clearPaid();
if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) {
for (Effect effect : executingEffects) {