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

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package org.mage.test.cards.abilities.other; package org.mage.test.cards.abilities.other;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
@ -40,16 +39,12 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class SoulfireGrandMasterTest extends CardTestPlayerBase { public class SoulfireGrandMasterTest extends CardTestPlayerBase {
/** /**
* Soulfire Grand Master * Soulfire Grand Master Creature - Human Monk 2/2, 1W (2) Lifelink Instant
* Creature - Human Monk 2/2, 1W (2) * and sorcery spells you control have lifelink. {2}{U/R}{U/R}: The next
* Lifelink * time you cast an instant or sorcery spell from your hand this turn, put
* Instant and sorcery spells you control have lifelink. * that card into your hand instead of into your graveyard as it resolves.
* {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 @Test
public void testSpellsGainLifelink() { public void testSpellsGainLifelink() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
@ -87,12 +82,11 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
assertLife(playerB, 17); assertLife(playerB, 17);
} }
/** /**
* Test with Searing Blood * Test with Searing Blood If the delayed triggered ability triggers, it has
* If the delayed triggered ability triggers, it has to give * to give life from lifelink because the source is still Searing Blood
* 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 @Test
public void testSearingBlood1() { public void testSearingBlood1() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
@ -117,9 +111,8 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
} }
/** /**
* Test with Searing Blood * Test with Searing Blood If the delayed triggered ability triggers, it has
* If the delayed triggered ability triggers, it has to give * to give life from lifelink because the source is still Searing Blood
* life from lifelink because the source is still Searing Blood
*/ */
@Test @Test
public void testSearinBlood2() { 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 damage of activated ability of a permanent does not gain lifelink
* *
*/ */
@Test @Test
public void testActivatedAbility() { public void testActivatedAbility() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
@ -203,9 +194,10 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
assertLife(playerA, 20); assertLife(playerA, 20);
} }
/** /**
* Test that if Soulfire Grand Master has left the battlefield * Test that if Soulfire Grand Master has left the battlefield spell has no
* spell has no longer lifelink * longer lifelink
*/ */
@Test @Test
@ -232,10 +224,12 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
assertLife(playerA, 20); assertLife(playerA, 20);
} }
/** /**
* I activated the ability of Soulfire grand master, it resolved, then i cast Stoke the Flames * I activated the ability of Soulfire grand master, it resolved, then i
* on Whisperwood Elemental, my opponenet sacrificed the elemental, so stoke didnt resolve, * cast Stoke the Flames on Whisperwood Elemental, my opponenet sacrificed
* but i still got the life from lifelink. * the elemental, so stoke didnt resolve, but i still got the life from
* lifelink.
*/ */
@Test @Test
@ -250,7 +244,7 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}{U/R}{U/R}:"); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{2}{U/R}{U/R}:");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Stoke the Flames", "Whisperwood Elemental"); castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Stoke the Flames", "Whisperwood Elemental");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Sacrifice {this}", null ,"{this} deals 4 damage"); activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Sacrifice {this}", null, "{this} deals 4 damage");
setStopAt(1, PhaseStep.END_TURN); setStopAt(1, PhaseStep.END_TURN);
execute(); execute();
@ -263,12 +257,11 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
} }
/** /**
* Check if second ability resolved, the next spell that is counterer * Check if second ability resolved, the next spell that is counterer won't
* won't go to hand back because it did not resolve * go to hand back because it did not resolve
* *
*/ */
@Test @Test
public void testSoulfireCounteredSpellDontGoesBack() { public void testSoulfireCounteredSpellDontGoesBack() {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 8); addCard(Zone.BATTLEFIELD, playerA, "Mountain", 8);
@ -295,10 +288,12 @@ public class SoulfireGrandMasterTest extends CardTestPlayerBase {
assertLife(playerA, 20); 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. * With a Soulfire Grand Master in play, Deflecting Palm doesn't gain the
* I was playing against a human in Standard Constructed. * 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 * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.abilities.effects.common.continuous; package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.AttachmentType; import mage.constants.AttachmentType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer; import mage.constants.Layer;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubLayer; import mage.constants.SubLayer;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
@ -70,7 +69,7 @@ public class GainAbilityAttachedEffect extends ContinuousEffectImpl {
setText(); setText();
} }
public GainAbilityAttachedEffect(Ability ability, AttachmentType attachmentType) { public GainAbilityAttachedEffect(Ability ability, AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.ability = ability; this.ability = ability;
this.attachmentType = attachmentType; this.attachmentType = attachmentType;

View file

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

View file

@ -77,12 +77,12 @@ import mage.watchers.Watchers;
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
* *
* since at any time the game state may be copied and restored you cannot rely * since at any time the game state may be copied and restored you cannot rely
* on any object maintaining it's instance it then becomes necessary to only * on any object maintaining it's instance it then becomes necessary to only
* refer to objects by their ids since these will always remain constant * refer to objects by their ids since these will always remain constant
* throughout its lifetime * throughout its lifetime
* *
*/ */
public class GameState implements Serializable, Copyable<GameState> { public class GameState implements Serializable, Copyable<GameState> {
private static final transient ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(1024); private static final transient ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(1024);
@ -643,7 +643,7 @@ public class GameState implements Serializable, Copyable<GameState> {
} }
public void handleSimultaneousEvent(Game game) { 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 // it can happen, that the events add new simultaneous events, so copy the list before
List<GameEvent> eventsToHandle = new ArrayList<>(); List<GameEvent> eventsToHandle = new ArrayList<>();
eventsToHandle.addAll(simultaneousEvents); eventsToHandle.addAll(simultaneousEvents);