From b828cce8fe3b0bc3441ba2f9a2ef2bdc770868e6 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 26 Oct 2014 09:24:57 +0100 Subject: [PATCH] * Living Death - Fixed bug that happened as graveyard was empty if Living Death was cast. --- Mage.Sets/src/mage/sets/tempest/LivingDeath.java | 14 ++++++++++---- Mage.Sets/src/mage/sets/theros/DaxosOfMeletis.java | 7 ++++++- Mage.Sets/src/mage/sets/timespiral/LivingEnd.java | 8 +++++--- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Mage.Sets/src/mage/sets/tempest/LivingDeath.java b/Mage.Sets/src/mage/sets/tempest/LivingDeath.java index 23125ffb530..3e7c5cd36ab 100644 --- a/Mage.Sets/src/mage/sets/tempest/LivingDeath.java +++ b/Mage.Sets/src/mage/sets/tempest/LivingDeath.java @@ -28,6 +28,7 @@ package mage.sets.tempest; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; @@ -38,6 +39,7 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterCreatureCard; import mage.filter.common.FilterCreaturePermanent; +import mage.game.ExileZone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -85,13 +87,14 @@ class LivingDeathEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { // move creature cards from graveyard to exile for (UUID playerId: controller.getInRange()){ Player player = game.getPlayer(playerId); if (player != null) { for (Card card :player.getGraveyard().getCards(new FilterCreatureCard(), game)) { - card.moveToExile(source.getSourceId(), "Living End", source.getSourceId(), game); + controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getLogName(), source.getSourceId(), game, Zone.GRAVEYARD); } } } @@ -100,8 +103,11 @@ class LivingDeathEffect extends OneShotEffect { permanent.sacrifice(source.getSourceId(), game); } // put exiled cards to battlefield - for (Card card : game.getState().getExile().getExileZone(source.getSourceId()).getCards(game)) { - card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId()); + ExileZone exileZone = game.getState().getExile().getExileZone(source.getSourceId()); + if (exileZone != null) { + for (Card card : exileZone.getCards(game)) { + controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); + } } return true; } diff --git a/Mage.Sets/src/mage/sets/theros/DaxosOfMeletis.java b/Mage.Sets/src/mage/sets/theros/DaxosOfMeletis.java index 6c01874f777..0fc00218b80 100644 --- a/Mage.Sets/src/mage/sets/theros/DaxosOfMeletis.java +++ b/Mage.Sets/src/mage/sets/theros/DaxosOfMeletis.java @@ -48,6 +48,7 @@ import mage.constants.Zone; import mage.filter.Filter; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.PowerPredicate; +import mage.game.ExileZone; import mage.game.Game; import mage.players.Player; import mage.target.targetpointer.FixedTarget; @@ -173,7 +174,11 @@ class DaxosOfMeletisCastFromExileEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { - return sourceId.equals(cardId) && game.getState().getExile().getExileZone(exileId).contains(cardId); + if (sourceId.equals(cardId)) { + ExileZone exileZone = game.getState().getExile().getExileZone(exileId); + return exileZone != null && exileZone.contains(cardId); + } + return false; } } diff --git a/Mage.Sets/src/mage/sets/timespiral/LivingEnd.java b/Mage.Sets/src/mage/sets/timespiral/LivingEnd.java index 530da3e77d9..cc95e6e7328 100644 --- a/Mage.Sets/src/mage/sets/timespiral/LivingEnd.java +++ b/Mage.Sets/src/mage/sets/timespiral/LivingEnd.java @@ -28,6 +28,7 @@ package mage.sets.timespiral; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; @@ -93,13 +94,14 @@ class LivingEndEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { // move creature cards from graveyard to exile for (UUID playerId: controller.getInRange()){ Player player = game.getPlayer(playerId); if (player != null) { for (Card card :player.getGraveyard().getCards(new FilterCreatureCard(), game)) { - card.moveToExile(source.getSourceId(), "Living End", source.getSourceId(), game); + controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getLogName(), source.getSourceId(), game, Zone.GRAVEYARD); } } } @@ -111,7 +113,7 @@ class LivingEndEffect extends OneShotEffect { ExileZone exileZone = game.getState().getExile().getExileZone(source.getSourceId()); if (exileZone != null) { for (Card card : exileZone.getCards(game)) { - card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId()); + controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); } } return true;