mirror of
https://github.com/correl/mage.git
synced 2024-12-29 19:15:06 +00:00
[C13] Fixed Jeleva not exiling cards if killed in response to trigger. Closes #3476.
This commit is contained in:
parent
632f10adf2
commit
cbecdefb9f
2 changed files with 53 additions and 4 deletions
|
@ -15,6 +15,7 @@ import mage.constants.*;
|
|||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
@ -81,18 +82,18 @@ class JelevaNephaliasScourgeEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
JelevaNephaliasWatcher watcher = game.getState().getWatcher(JelevaNephaliasWatcher.class);
|
||||
if (controller != null
|
||||
&& sourceObject != null
|
||||
&& permanent != null
|
||||
&& watcher != null) {
|
||||
int xValue = watcher.getManaSpentToCastLastTime(sourceObject.getId(), sourceObject.getZoneChangeCounter(game) - 1);
|
||||
int xValue = watcher.getManaSpentToCastLastTime(permanent.getId(), permanent.getZoneChangeCounter(game) - 1);
|
||||
if (xValue > 0) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.moveCardsToExile(player.getLibrary().getTopCards(game, xValue),
|
||||
source, game, true, CardUtil.getCardExileZoneId(game, source), sourceObject.getIdName());
|
||||
source, game, true, CardUtil.getCardExileZoneId(game, source), permanent.getIdName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package org.mage.test.cards.single.c13;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* {@link mage.cards.j.JelevaNephaliasScourge Jeleva, Nephalia's Scourge}
|
||||
* {1}{U}{B}{R}
|
||||
* Flying
|
||||
* When Jeleva, Nephalia’s Scourge enters the battlefield, each player exiles the top X cards of their library,
|
||||
* where X is the amount of mana spent to cast Jeleva.
|
||||
* Whenever Jeleva attacks, you may cast an instant or sorcery spell from among cards exiled with Jeleva without paying its mana cost.
|
||||
*/
|
||||
public class JelevaNephaliasScourgeTest extends CardTestPlayerBase {
|
||||
private static final String jeleva = "Jeleva, Nephalia's Scourge";
|
||||
|
||||
/**
|
||||
* Reported bug: https://github.com/magefree/mage/issues/3476
|
||||
* When casting Jeleva, Nephalia's Scourge,
|
||||
* if Jeleva is no longer on the battlefield when her ETB trigger resolves,
|
||||
* she won't exile any cards.
|
||||
*/
|
||||
@Test
|
||||
public void etbWorksIfShesRemoved() {
|
||||
addCard(Zone.HAND, playerA, jeleva);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
|
||||
|
||||
// Destroy target Creature
|
||||
String murder = "Murder";
|
||||
addCard(Zone.HAND, playerB, murder);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Swamp", 3);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, jeleva);
|
||||
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, 1);
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, murder, jeleva);
|
||||
|
||||
setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, jeleva, 1);
|
||||
assertExileCount(playerA, 4);
|
||||
assertExileCount(playerB, 4);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue