* Living Death - Fixed bug that happened as graveyard was empty if Living Death was cast.

This commit is contained in:
LevelX2 2014-10-26 09:24:57 +01:00
parent 9905b0c4ab
commit b828cce8fe
3 changed files with 21 additions and 8 deletions

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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;