From 596e2f7f19737755f377b46b48c6fa76ad6e9095 Mon Sep 17 00:00:00 2001 From: Quercitron Date: Mon, 2 May 2016 16:06:56 +0300 Subject: [PATCH] Fix DoIfCostPaid effect when it is not optional. --- .../cards/conditional/DoIfCostPaidTest.java | 32 +++++++++++++++++++ .../effects/common/DoIfCostPaid.java | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/conditional/DoIfCostPaidTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/conditional/DoIfCostPaidTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/conditional/DoIfCostPaidTest.java new file mode 100644 index 00000000000..450d6927779 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/conditional/DoIfCostPaidTest.java @@ -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); + } + +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java b/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java index 607dd2c23ac..6edef3c794e 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoIfCostPaid.java @@ -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) {