* Fixed a bug with Infernal Scarring that the ability did not trigger that let you draw a card as the enchanted creature died.

This commit is contained in:
LevelX2 2015-06-30 12:29:17 +02:00
parent 490d83774c
commit a174bef27b
6 changed files with 157 additions and 101 deletions

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.abilities.other;
import mage.constants.PhaseStep;
@ -42,16 +41,12 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class MycosynthGolemTest extends CardTestPlayerBase {
/**
* Mycosynth Golem
* Artifact Creature Golem 4/5, 11 (11)
* Affinity for artifacts (This spell costs {1} less to cast for each
* artifact you control.)
* Artifact creature spells you cast have affinity for artifacts. (They cost
* {1} less to cast for each artifact you control.)
* Mycosynth Golem Artifact Creature Golem 4/5, 11 (11) Affinity for
* artifacts (This spell costs {1} less to cast for each artifact you
* control.) Artifact creature spells you cast have affinity for artifacts.
* (They cost {1} less to cast for each artifact you control.)
*
*/
// @Ignore // at this time player.getPlayable() does not account for spells that gain abilities
@Test
public void testSpellsAffinity() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.abilities.other;
import mage.constants.PhaseStep;
@ -40,16 +39,12 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class SoulfireGrandMasterTest extends CardTestPlayerBase {
/**
* Soulfire Grand Master
* Creature - Human Monk 2/2, 1W (2)
* Lifelink
* Instant and sorcery spells you control have lifelink.
* {2}{U/R}{U/R}: The next time you cast an instant or sorcery spell from
* your hand this turn, put that card into your hand instead of into your
* graveyard as it resolves.
* Soulfire Grand Master Creature - Human Monk 2/2, 1W (2) Lifelink Instant
* and sorcery spells you control have lifelink. {2}{U/R}{U/R}: The next
* time you cast an instant or sorcery spell from your hand this turn, put
* that card into your hand instead of into your graveyard as it resolves.
*
*/
@Test
public void testSpellsGainLifelink() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
@ -87,12 +82,11 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
assertLife(playerB, 17);
}
/**
* Test with Searing Blood
* If the delayed triggered ability triggers, it has to give
* life from lifelink because the source is still Searing Blood
* Test with Searing Blood If the delayed triggered ability triggers, it has
* to give life from lifelink because the source is still Searing Blood
*/
// @Ignore // Does not work because as the delayed triggered ability resolves, the source card is no longer on the stack and
@Test
public void testSearingBlood1() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
@ -117,9 +111,8 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
}
/**
* Test with Searing Blood
* If the delayed triggered ability triggers, it has to give
* life from lifelink because the source is still Searing Blood
* Test with Searing Blood If the delayed triggered ability triggers, it has
* to give life from lifelink because the source is still Searing Blood
*/
@Test
public void testSearinBlood2() {
@ -176,12 +169,10 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
}
/**
* Test damage of activated ability of a permanent does not gain lifelink
*
*/
@Test
public void testActivatedAbility() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
@ -203,9 +194,10 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
assertLife(playerA, 20);
}
/**
* Test that if Soulfire Grand Master has left the battlefield
* spell has no longer lifelink
* Test that if Soulfire Grand Master has left the battlefield spell has no
* longer lifelink
*/
@Test
@ -232,10 +224,12 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
assertLife(playerA, 20);
}
/**
* I activated the ability of Soulfire grand master, it resolved, then i cast Stoke the Flames
* on Whisperwood Elemental, my opponenet sacrificed the elemental, so stoke didnt resolve,
* but i still got the life from lifelink.
* I activated the ability of Soulfire grand master, it resolved, then i
* cast Stoke the Flames on Whisperwood Elemental, my opponenet sacrificed
* the elemental, so stoke didnt resolve, but i still got the life from
* lifelink.
*/
@Test
@ -264,11 +258,10 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
}
/**
* Check if second ability resolved, the next spell that is counterer
* won't go to hand back because it did not resolve
* Check if second ability resolved, the next spell that is counterer won't
* go to hand back because it did not resolve
*
*/
@Test
public void testSoulfireCounteredSpellDontGoesBack() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 8);
@ -295,10 +288,12 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
assertLife(playerA, 20);
}
/**
* With a Soulfire Grand Master in play, Deflecting Palm doesn't gain the caster life.
* It should as it has lifelink, and it's Deflecting Palm (an instant) dealing damage.
* I was playing against a human in Standard Constructed.
* With a Soulfire Grand Master in play, Deflecting Palm doesn't gain the
* caster life. It should as it has lifelink, and it's Deflecting Palm (an
* instant) dealing damage. I was playing against a human in Standard
* Constructed.
*
*/

View file

@ -0,0 +1,69 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package org.mage.test.cards.triggers.dies;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class GainedDiesTriggersTest extends CardTestPlayerBase {
/**
* Tests that gained dies triggers work as intended
*/
@Test
public void testInfernalScarring() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 3);
// Enchant creature
// Enchanted creature gets +2/+0 and has "When this creature dies, draw a card."
addCard(Zone.HAND, playerA, "Infernal Scarring", 1);
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 1);
addCard(Zone.HAND, playerB, "Lightning Bolt", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Infernal Scarring", "Silvercoat Lion");
// Destroy all creatures.
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Silvercoat Lion");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
assertGraveyardCount(playerB, "Lightning Bolt", 1);
assertHandCount(playerA, 1); // draw a card for dying Lion
}
}

View file

@ -25,16 +25,15 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.AttachmentType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;

View file

@ -1432,19 +1432,17 @@ public abstract class GameImpl implements Game, Serializable {
*/
@Override
public boolean checkStateAndTriggered() {
boolean trigger = !getTurn().isEndTurnRequested();
boolean somethingHappened = false;
//20091005 - 115.5
while (!isPaused() && !gameOver(null)) {
if (!checkStateBasedActions()) {
// nothing happened so check triggers
if (trigger) {
state.handleSimultaneousEvent(this);
}
if (isPaused() || gameOver(null) || !trigger || !checkTriggered()) {
if (isPaused() || gameOver(null) || getTurn().isEndTurnRequested() || !checkTriggered()) {
break;
}
}
state.handleSimultaneousEvent(this);
applyEffects(); // needed e.g if boost effects end and cause creatures to die
somethingHappened = true;
}

View file

@ -643,7 +643,7 @@ public class GameState implements Serializable, Copyable<GameState> {
}
public void handleSimultaneousEvent(Game game) {
if (!simultaneousEvents.isEmpty()) {
if (!simultaneousEvents.isEmpty() && !getTurn().isEndTurnRequested()) {
// it can happen, that the events add new simultaneous events, so copy the list before
List<GameEvent> eventsToHandle = new ArrayList<>();
eventsToHandle.addAll(simultaneousEvents);