fixed various instances of getting source name (fixes #8531, fixes #8528)

This commit is contained in:
Evan Kranzler 2021-12-24 19:30:31 -05:00
parent 8791f30b4a
commit a6fcaab698
29 changed files with 54 additions and 94 deletions

View file

@ -1,7 +1,6 @@
package mage.cards.b; package mage.cards.b;
import mage.MageInt; import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -111,12 +110,11 @@ class BaneAlleyBrokerDrawExileEffect extends OneShotEffect {
TargetCard target = new TargetCardInHand().withChooseHint("to exile"); TargetCard target = new TargetCardInHand().withChooseHint("to exile");
controller.chooseTarget(outcome, controller.getHand(), target, source, game); controller.chooseTarget(outcome, controller.getHand(), target, source, game);
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
MageObject sourceObject = source.getSourcePermanentOrLKI(game); if (card == null) {
if (card == null || sourceObject == null) {
return false; return false;
} }
if (!controller.moveCardsToExile( if (!controller.moveCardsToExile(
card, source, game, false, CardUtil.getExileZoneId(game, source), sourceObject.getIdName() card, source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)
)) { )) {
return false; return false;
} }

View file

@ -1,6 +1,5 @@
package mage.cards.b; package mage.cards.b;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -67,15 +66,14 @@ class BottledCloisterExileEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); if (controller == null) {
if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(controller.getHand()); Cards cards = new CardsImpl(controller.getHand());
if (cards.isEmpty()) { if (cards.isEmpty()) {
return false; return false;
} }
controller.moveCardsToExile(cards.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), sourceObject.getIdName()); controller.moveCardsToExile(cards.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
cards.getCards(game) cards.getCards(game)
.stream() .stream()
.filter(c -> game.getState().getZone(c.getId()) == Zone.EXILED) .filter(c -> game.getState().getZone(c.getId()) == Zone.EXILED)

View file

@ -27,11 +27,11 @@ import mage.target.common.TargetAnyTarget;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetCardInYourGraveyard; import mage.target.common.TargetCardInYourGraveyard;
import mage.target.targetpointer.FixedTargets; import mage.target.targetpointer.FixedTargets;
import mage.util.CardUtil;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.util.CardUtil;
/** /**
* @author htrajan * @author htrajan
@ -117,8 +117,7 @@ class ChandraHeartOfFireUltimateEffect extends OneShotEffect {
} }
// exile cards all at once and set the exile name to the source card // exile cards all at once and set the exile name to the source card
Card sourceCard = game.getCard(source.getSourceId()); controller.moveCardsToExile(exiledCards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
controller.moveCardsToExile(exiledCards, source, game, true, CardUtil.getExileZoneId(game, source), sourceCard.getName());
controller.shuffleLibrary(source, game); controller.shuffleLibrary(source, game);
exiledCards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId()))); exiledCards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));

View file

@ -154,7 +154,7 @@ class CurseOfHospitalityEffect extends OneShotEffect {
enchanted.moveCardsToExile( enchanted.moveCardsToExile(
card, source, game, true, card, source, game, true,
CardUtil.getExileZoneId(game, source), CardUtil.getExileZoneId(game, source),
CardUtil.getSourceLogName(game, source) CardUtil.getSourceName(game, source)
); );
Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player == null) { if (player == null) {

View file

@ -83,12 +83,8 @@ class DarkImpostorExileTargetEffect extends OneShotEffect {
if (player == null || permanent == null) { if (player == null || permanent == null) {
return false; return false;
} }
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (sourcePermanent == null) {
return player.moveCards(permanent, Zone.EXILED, source, game);
}
return player.moveCardsToExile( return player.moveCardsToExile(
permanent, source, game, true, CardUtil.getExileZoneId(game, source), sourcePermanent.getIdName() permanent, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)
); );
} }
} }

View file

@ -8,7 +8,6 @@ import mage.cards.*;
import mage.constants.*; import mage.constants.*;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.common.TargetCardInExile; import mage.target.common.TargetCardInExile;
@ -68,8 +67,7 @@ class EndlessHorizonsEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentOrLKI(game); if (player == null) {
if (permanent == null || player == null) {
return false; return false;
} }
TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter); TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, filter);
@ -80,7 +78,7 @@ class EndlessHorizonsEffect extends OneShotEffect {
.map(uuid -> player.getLibrary().getCard(uuid, game)) .map(uuid -> player.getLibrary().getCard(uuid, game))
.filter(Objects::nonNull) .filter(Objects::nonNull)
.forEach(cards::add); .forEach(cards::add);
player.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), permanent.getIdName()); player.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
player.shuffleLibrary(source, game); player.shuffleLibrary(source, game);
return true; return true;
} }

View file

@ -1,7 +1,6 @@
package mage.cards.f; package mage.cards.f;
import mage.MageInt; import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -77,8 +76,7 @@ class FiendOfTheShadowsEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player player = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game); if (player == null || player.getHand().isEmpty()) {
if (player == null || sourceObject == null || player.getHand().isEmpty()) {
return false; return false;
} }
TargetCard targetCard = new TargetDiscard(player.getId()); TargetCard targetCard = new TargetDiscard(player.getId());
@ -88,7 +86,7 @@ class FiendOfTheShadowsEffect extends OneShotEffect {
return false; return false;
} }
player.moveCardToExileWithInfo( player.moveCardToExileWithInfo(
card, CardUtil.getExileZoneId(game, source), sourceObject.getName(), card, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source),
source, game, Zone.HAND, true source, game, Zone.HAND, true
); );
CardUtil.makeCardPlayable(game, source, card, Duration.Custom, false); CardUtil.makeCardPlayable(game, source, card, Duration.Custom, false);

View file

@ -16,7 +16,6 @@ import mage.constants.Zone;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.ExileZone; import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
@ -69,15 +68,14 @@ class FreeForAllExileAllEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = source.getSourcePermanentOrLKI(game); if (player == null) {
if (player == null || sourcePermanent == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
game.getBattlefield().getActivePermanents( game.getBattlefield().getActivePermanents(
StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game
).stream().forEach(cards::add); ).stream().forEach(cards::add);
player.moveCardsToExile(cards.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), sourcePermanent.getIdName()); player.moveCardsToExile(cards.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
cards.getCards(game) cards.getCards(game)
.stream() .stream()
.filter(card -> game.getState().getZone(card.getId()) == Zone.EXILED) .filter(card -> game.getState().getZone(card.getId()) == Zone.EXILED)

View file

@ -89,7 +89,7 @@ class GisaGloriousResurrectorExileEffect extends ReplacementEffectImpl {
+ game.getState().getZoneChangeCounter(source.getSourceId()), source); + game.getState().getZoneChangeCounter(source.getSourceId()), source);
return player.moveCardsToExile( return player.moveCardsToExile(
zEvent.getTarget(), source, game, false, zEvent.getTarget(), source, game, false,
CardUtil.getExileZoneId(game, source), "Gisa, Glorious Resurrector" CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)
); );
} }

View file

@ -1,6 +1,5 @@
package mage.cards.h; package mage.cards.h;
import mage.MageObject;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@ -72,17 +71,15 @@ class HedonistsTroveExileEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget()); Player targetPlayer = game.getPlayer(source.getFirstTarget());
MageObject sourceObject = source.getSourceObject(game);
UUID exileId = CardUtil.getExileZoneId(game, source); UUID exileId = CardUtil.getExileZoneId(game, source);
// save the exileId associated with this specific source // save the exileId associated with this specific source
game.getState().setValue(source.getSourceId().toString(), exileId); game.getState().setValue(source.getSourceId().toString(), exileId);
return controller != null return controller != null
&& targetPlayer != null && targetPlayer != null
&& sourceObject != null
&& controller.moveCardsToExile( && controller.moveCardsToExile(
targetPlayer.getGraveyard().getCards(game), source, game, true, targetPlayer.getGraveyard().getCards(game), source, game, true,
exileId, sourceObject.getIdName() exileId, CardUtil.getSourceName(game, source)
); );
} }
} }
@ -189,9 +186,9 @@ class HedonistsTroveWatcher extends Watcher {
Permanent permanent = source.getSourcePermanentOrLKI(game); Permanent permanent = source.getSourcePermanentOrLKI(game);
return permanent != null return permanent != null
&& playerMap && playerMap
.getOrDefault(playerId, emptySet) .getOrDefault(playerId, emptySet)
.stream() .stream()
.noneMatch(mor -> mor.refersTo(permanent, game)); .noneMatch(mor -> mor.refersTo(permanent, game));
} }
@Override @Override

View file

@ -16,7 +16,6 @@ import mage.constants.SubType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.ExileZone; import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetOpponent; import mage.target.common.TargetOpponent;
import mage.util.CardUtil; import mage.util.CardUtil;
@ -77,13 +76,12 @@ class HypnoxExileEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget()); Player player = game.getPlayer(source.getFirstTarget());
Permanent permanent = source.getSourcePermanentOrLKI(game); if (controller == null || player == null) {
if (controller == null || player == null || permanent == null) {
return false; return false;
} }
return controller.moveCardsToExile( return controller.moveCardsToExile(
player.getHand().getCards(game), source, game, true, player.getHand().getCards(game), source, game, true,
CardUtil.getExileZoneId(game, source), permanent.getIdName() CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)
); );
} }

View file

@ -1,6 +1,5 @@
package mage.cards.i; package mage.cards.i;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
@ -63,12 +62,11 @@ class IgnorantBlissEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); if (controller == null) {
if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards hand = new CardsImpl(controller.getHand()); Cards hand = new CardsImpl(controller.getHand());
controller.moveCardsToExile(hand.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), sourceObject.getIdName()); controller.moveCardsToExile(hand.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
hand.getCards(game) hand.getCards(game)
.stream() .stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)

View file

@ -1,6 +1,5 @@
package mage.cards.i; package mage.cards.i;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility; import mage.abilities.common.PutIntoGraveFromBattlefieldSourceTriggeredAbility;
@ -66,8 +65,7 @@ class InducedAmnesiaExileEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source)); Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = source.getSourceObject(game); if (targetPlayer == null) {
if (targetPlayer == null || sourceObject == null) {
return false; return false;
} }
int numberOfCards = targetPlayer.getHand().size(); int numberOfCards = targetPlayer.getHand().size();
@ -77,7 +75,7 @@ class InducedAmnesiaExileEffect extends OneShotEffect {
Cards cards = new CardsImpl(targetPlayer.getHand()); Cards cards = new CardsImpl(targetPlayer.getHand());
targetPlayer.moveCardsToExile( targetPlayer.moveCardsToExile(
cards.getCards(game), source, game, false, cards.getCards(game), source, game, false,
CardUtil.getExileZoneId(game, source), sourceObject.getIdName() CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)
); );
cards.getCards(game) cards.getCards(game)
.stream() .stream()

View file

@ -1,6 +1,5 @@
package mage.cards.l; package mage.cards.l;
import mage.MageObject;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -97,8 +96,7 @@ class LegionsInitiativeExileEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); if (player == null) {
if (player == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
@ -108,7 +106,7 @@ class LegionsInitiativeExileEffect extends OneShotEffect {
).stream().filter(Objects::nonNull).forEach(cards::add); ).stream().filter(Objects::nonNull).forEach(cards::add);
return player.moveCardsToExile( return player.moveCardsToExile(
cards.getCards(game), source, game, true, cards.getCards(game), source, game, true,
CardUtil.getExileZoneId(game, source), sourceObject.getIdName() CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)
); );
} }

View file

@ -103,7 +103,7 @@ class MindFlayerTheShadowExileEffect extends OneShotEffect {
controller.moveCardsToExile( controller.moveCardsToExile(
cards.getCards(game), source, game, false, cards.getCards(game), source, game, false,
CardUtil.getExileZoneId(game, source), CardUtil.getExileZoneId(game, source),
CardUtil.getSourceLogName(game, source) CardUtil.getSourceName(game, source)
); );
cards.getCards(game).stream().forEach(card -> card.setFaceDown(true, game)); cards.getCards(game).stream().forEach(card -> card.setFaceDown(true, game));
for (Card card : cards.getCards(game)) { for (Card card : cards.getCards(game)) {

View file

@ -1,7 +1,6 @@
package mage.cards.m; package mage.cards.m;
import mage.MageInt; import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
@ -112,14 +111,13 @@ class MindreaverExileEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget()); Player player = game.getPlayer(source.getFirstTarget());
MageObject mageObject = source.getSourceObject(game); if (controller == null || player == null) {
if (controller == null || player == null || mageObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 3)); Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 3));
return controller.moveCardsToExile( return controller.moveCardsToExile(
cards.getCards(game), source, game, true, cards.getCards(game), source, game, true,
CardUtil.getExileZoneId(game, source), mageObject.getIdName() CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source)
); );
} }
} }

View file

@ -85,7 +85,7 @@ class MnemonicBetrayalExileEffect extends OneShotEffect {
.forEach(cards::addAll); .forEach(cards::addAll);
controller.moveCardsToExile( controller.moveCardsToExile(
cards.getCards(game), source, game, true, cards.getCards(game), source, game, true,
source.getSourceId(), CardUtil.getSourceLogName(game, source) source.getSourceId(), CardUtil.getSourceName(game, source)
); );
for (Card card : cards.getCards(game)) { for (Card card : cards.getCards(game)) {
if (card.isLand(game)) { if (card.isLand(game)) {

View file

@ -79,7 +79,7 @@ class ProwlingGeistcatcherExileEffect extends OneShotEffect {
player.moveCardsToExile( player.moveCardsToExile(
card, source, game, true, card, source, game, true,
CardUtil.getExileZoneId(game, source), CardUtil.getExileZoneId(game, source),
CardUtil.getSourceLogName(game, source) CardUtil.getSourceName(game, source)
); );
} }
Permanent exiled = (Permanent) getValue("sacrificedPermanent"); Permanent exiled = (Permanent) getValue("sacrificedPermanent");

View file

@ -1,6 +1,5 @@
package mage.cards.p; package mage.cards.p;
import mage.MageObject;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
@ -71,11 +70,10 @@ class PsychicTheftEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(targetPointer.getFirst(game, source)); Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
MageObject sourceObject = game.getObject(source.getSourceId()); if (opponent == null) {
if (opponent == null || sourceObject == null) {
return false; return false;
} }
opponent.revealCards(sourceObject.getName(), opponent.getHand(), game); opponent.revealCards(CardUtil.getSourceName(game, source), opponent.getHand(), game);
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller == null) { if (controller == null) {
return false; return false;
@ -91,8 +89,7 @@ class PsychicTheftEffect extends OneShotEffect {
if (chosenCard == null) { if (chosenCard == null) {
return false; return false;
} }
UUID exileId = CardUtil.getExileZoneId(game, source); controller.moveCardToExileWithInfo(chosenCard, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source), source, game, Zone.HAND, true);
controller.moveCardToExileWithInfo(chosenCard, exileId, sourceObject.getIdName(), source, game, Zone.HAND, true);
CardUtil.makeCardPlayable(game, source, chosenCard, Duration.Custom, false); CardUtil.makeCardPlayable(game, source, chosenCard, Duration.Custom, false);

View file

@ -14,7 +14,6 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
import mage.watchers.common.AttackedThisTurnWatcher; import mage.watchers.common.AttackedThisTurnWatcher;
@ -120,13 +119,12 @@ class RobberOfTheRichEffect extends OneShotEffect {
if (controller == null || damagedPlayer == null) { if (controller == null || damagedPlayer == null) {
return false; return false;
} }
Permanent sourceObject = source.getSourcePermanentIfItStillExists(game);
Card card = damagedPlayer.getLibrary().getFromTop(game); Card card = damagedPlayer.getLibrary().getFromTop(game);
if (card == null || sourceObject == null) { if (card == null) {
return false; return false;
} }
// move card to exile // move card to exile
controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source), sourceObject.getIdName()); controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
// Add effects only if the card has a spellAbility (e.g. not for lands). // Add effects only if the card has a spellAbility (e.g. not for lands).
if (card.getSpellAbility() != null) { if (card.getSpellAbility() != null) {
// allow to cast the card // allow to cast the card

View file

@ -1,6 +1,5 @@
package mage.cards.r; package mage.cards.r;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility; import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -103,11 +102,10 @@ class RogueClassExileEffect extends OneShotEffect {
if (card == null) { if (card == null) {
return false; return false;
} }
MageObject sourceObject = source.getSourcePermanentOrLKI(game);
controller.moveCardsToExile( controller.moveCardsToExile(
card, source, game, false, card, source, game, false,
CardUtil.getExileZoneId(game, source), CardUtil.getExileZoneId(game, source),
sourceObject != null ? sourceObject.getName() : null CardUtil.getSourceName(game, source)
); );
card.setFaceDown(true, game); card.setFaceDown(true, game);
game.addEffect(new RogueClassLookEffect().setTargetPointer(new FixedTarget(card, game)), source); game.addEffect(new RogueClassLookEffect().setTargetPointer(new FixedTarget(card, game)), source);

View file

@ -85,7 +85,7 @@ class WallOfMourningExileEffect extends OneShotEffect {
player.moveCardsToExile( player.moveCardsToExile(
cards, source, game, false, cards, source, game, false,
CardUtil.getExileZoneId(game, source), CardUtil.getExileZoneId(game, source),
CardUtil.getSourceLogName(game, source) CardUtil.getSourceName(game, source)
); );
for (Card card : cards) { for (Card card : cards) {
card.setFaceDown(true, game); card.setFaceDown(true, game);

View file

@ -1,7 +1,6 @@
package mage.cards.w; package mage.cards.w;
import mage.ApprovingObject; import mage.ApprovingObject;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -103,8 +102,7 @@ class WizardsSpellbookEffect extends OneShotEffect {
return false; return false;
} }
UUID exileId = CardUtil.getExileZoneId(game, source); UUID exileId = CardUtil.getExileZoneId(game, source);
MageObject sourceObject = source.getSourcePermanentOrLKI(game); player.moveCardsToExile(card, source, game, true, exileId, CardUtil.getSourceName(game, source));
player.moveCardsToExile(card, source, game, true, exileId, sourceObject != null ? sourceObject.getName() : null);
if (level < 3) { if (level < 3) {
Card copiedCard = game.copyCard(card, source, source.getControllerId()); Card copiedCard = game.copyCard(card, source, source.getControllerId());
if (!player.chooseUse( if (!player.chooseUse(

View file

@ -89,11 +89,10 @@ public class ExileFromGraveCost extends CostImpl {
} }
Cards cardsToExile = new CardsImpl(); Cards cardsToExile = new CardsImpl();
cardsToExile.addAll(exiledCards); cardsToExile.addAll(exiledCards);
Card sourceCard = game.getCard(source.getSourceId());
controller.moveCardsToExile( controller.moveCardsToExile(
cardsToExile.getCards(game), source, game, true, cardsToExile.getCards(game), source, game, true,
CardUtil.getExileZoneId(game, source), CardUtil.getExileZoneId(game, source),
sourceCard.getName() CardUtil.getSourceName(game, source)
); );
if (setTargetPointer) { if (setTargetPointer) {
source.getEffects().setTargetPointer(new FixedTargets(cardsToExile, game)); source.getEffects().setTargetPointer(new FixedTargets(cardsToExile, game));

View file

@ -1,6 +1,5 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Cards; import mage.cards.Cards;
@ -45,8 +44,7 @@ public class ExileAllEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); if (controller == null) {
if (controller == null || sourceObject == null) {
return false; return false;
} }
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
@ -54,7 +52,7 @@ public class ExileAllEffect extends OneShotEffect {
filter, source.getControllerId(), source.getSourceId(), game filter, source.getControllerId(), source.getSourceId(), game
).stream().forEach(cards::add); ).stream().forEach(cards::add);
if (forSource) { if (forSource) {
return controller.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), sourceObject.getName()); return controller.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
} }
return controller.moveCards(cards, Zone.EXILED, source, game); return controller.moveCards(cards, Zone.EXILED, source, game);

View file

@ -1,7 +1,6 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -55,7 +54,6 @@ public class ExileFromZoneTargetEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player player = game.getPlayer(targetPointer.getFirst(game, source));
MageObject mageObject = source.getSourceObject(game);
if (player == null) { if (player == null) {
return false; return false;
} }
@ -75,7 +73,7 @@ public class ExileFromZoneTargetEffect extends OneShotEffect {
target.chooseTarget(Outcome.Exile, player.getId(), source, game); target.chooseTarget(Outcome.Exile, player.getId(), source, game);
Cards cards = new CardsImpl(target.getTargets()); Cards cards = new CardsImpl(target.getTargets());
if (withSource) { if (withSource) {
return player.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), mageObject.getName()); return player.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
} }
return player.moveCards(cards, Zone.EXILED, source, game); return player.moveCards(cards, Zone.EXILED, source, game);
} }

View file

@ -58,8 +58,7 @@ public class ExileTopXMayPlayUntilEndOfTurnEffect extends OneShotEffect {
if (cards.isEmpty()) { if (cards.isEmpty()) {
return true; return true;
} }
Card sourceCard = game.getCard(source.getSourceId()); controller.moveCardsToExile(cards, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
controller.moveCardsToExile(cards, source, game, true, CardUtil.getExileZoneId(game, source), sourceCard.getName());
// remove cards that could not be moved to exile // remove cards that could not be moved to exile
cards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId()))); cards.removeIf(card -> !Zone.EXILED.equals(game.getState().getZone(card.getId())));
if (!cards.isEmpty()) { if (!cards.isEmpty()) {

View file

@ -1,6 +1,5 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -29,11 +28,10 @@ public class MistmeadowWitchEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getFirstTarget()); Permanent permanent = game.getPermanent(source.getFirstTarget());
MageObject sourceObject = source.getSourceObject(game); if (player == null || permanent == null) {
if (player == null || permanent == null || sourceObject == null) {
return false; return false;
} }
player.moveCardsToExile(permanent, source, game, true, CardUtil.getExileZoneId(game, source), sourceObject.getName()); player.moveCardsToExile(permanent, source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(Zone.BATTLEFIELD, "return the exiled card to the battlefield under its owner's control")), source); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(Zone.BATTLEFIELD, "return the exiled card to the battlefield under its owner's control")), source);
return true; return true;
} }

View file

@ -1229,6 +1229,11 @@ public final class CardUtil {
return false; return false;
} }
public static String getSourceName(Game game, Ability source) {
MageObject sourceObject = source.getSourceObject(game);
return sourceObject != null ? sourceObject.getName() : "";
}
/** /**
* Generates source log name to insert into log messages * Generates source log name to insert into log messages
* *