mirror of
https://github.com/correl/mage.git
synced 2025-04-11 01:01:05 -09:00
* Fixed that a delayed sacrifice source effect could create a null pointer exception.
This commit is contained in:
parent
77b32014f6
commit
20138891fe
3 changed files with 56 additions and 1 deletions
Mage.Tests/src/test/java/org/mage/test/cards/abilities
Mage/src/main/java/mage/abilities/effects/common
|
@ -213,4 +213,36 @@ public class TransformTest extends CardTestPlayerBase {
|
|||
Assert.assertFalse("Has not to have sorcery card type", nightmare.getCardType().contains(CardType.SORCERY));
|
||||
}
|
||||
|
||||
/**
|
||||
* When copy token of Lambholt Pacifist transforms with "its transform
|
||||
* ability", I see below error. Then rollback.
|
||||
*
|
||||
* 701.25a Only permanents represented by double-faced cards can transform.
|
||||
* (See rule 711, “Double-Faced Cards.”) If a spell or ability instructs a
|
||||
* player to transform any permanent that isn‘t represented by a
|
||||
* double-faced card, nothing happens.
|
||||
*/
|
||||
@Test
|
||||
public void testTransformCopy() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
|
||||
// Lambholt Pacifist can't attack unless you control a creature with power 4 or greater.
|
||||
// At the beginning of each upkeep, if no spells were cast last turn, transform Lambholt Pacifist.
|
||||
addCard(Zone.HAND, playerA, "Lambholt Pacifist"); // {1}{G}
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 4);
|
||||
// You may have Clone enter the battlefield as a copy of any creature on the battlefield.
|
||||
addCard(Zone.HAND, playerB, "Clone"); // {3}{U}
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lambholt Pacifist");
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Clone");
|
||||
setChoice(playerB, "Lambholt Pacifist");
|
||||
|
||||
setStopAt(4, PhaseStep.PRECOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Lambholt Butcher", 1);
|
||||
|
||||
assertPermanentCount(playerB, "Lambholt Pacifist", 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,4 +128,27 @@ public class NecromancyTest extends CardTestPlayerBase {
|
|||
assertGraveyardCount(playerA, "Craw Wurm", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* I was playing a legendary cube, flashed in a Necromancy to block and when
|
||||
* the creature I reanimated died the game bugged out and I lost.
|
||||
*/
|
||||
@Test
|
||||
public void testBlockWithNecromancyCreature() {
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 3);
|
||||
addCard(Zone.HAND, playerA, "Necromancy"); // {2}{B}
|
||||
addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
|
||||
|
||||
attack(2, playerB, "Silvercoat Lion");
|
||||
castSpell(2, PhaseStep.DECLARE_ATTACKERS, playerA, "Necromancy"); // enchanting the Silvercoat Lion
|
||||
block(2, playerA, "Silvercoat Lion", "Silvercoat Lion");
|
||||
|
||||
setStopAt(3, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Necromancy", 1);
|
||||
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
|
||||
assertGraveyardCount(playerB, "Silvercoat Lion", 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SacrificeSourceEffect extends OneShotEffect {
|
|||
// Check if the effect was installed by the spell the source was cast by (e.g. Necromancy), if not don't sacrifice the permanent
|
||||
if (source.getSourceObject(game) instanceof Spell) {
|
||||
sourceObject = game.getPermanent(source.getSourceId());
|
||||
if (sourceObject.getZoneChangeCounter(game) > source.getSourceObjectZoneChangeCounter() + 1) {
|
||||
if (sourceObject != null && sourceObject.getZoneChangeCounter(game) > source.getSourceObjectZoneChangeCounter() + 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue