From 9b51694908e6883e9301c80724c67a2062d938d5 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 11 Oct 2017 13:00:06 -0400 Subject: [PATCH] fixed embalm and eternalize sometimes giving the token to the wrong player --- .../mage/abilities/keyword/EmbalmAbility.java | 35 ++++++++------- .../abilities/keyword/EternalizeAbility.java | 45 ++++++++++--------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/keyword/EmbalmAbility.java b/Mage/src/main/java/mage/abilities/keyword/EmbalmAbility.java index c8a4aefa48..8d082c8076 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EmbalmAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EmbalmAbility.java @@ -105,23 +105,24 @@ class EmbalmEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getSourceId()); - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null && card != null) { - EmptyToken token = new EmptyToken(); - CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer) - token.getColor(game).setColor(ObjectColor.WHITE); - if (!token.hasSubtype(SubType.ZOMBIE, game)) { - token.getSubtype(game).add(0, SubType.ZOMBIE); - } - token.getManaCost().clear(); - game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EMBALMED_CREATURE, token.getId(), source.getSourceId(), controller.getId())); - token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false, null); - // Probably it makes sense to remove also the Embalm ability (it's not shown on the token cards). - // Also it can never get active or? But it's not mentioned in the reminder text. - return true; + if (card == null) { + return false; } - - return false; + Player controller = game.getPlayer(card.getOwnerId()); + if (controller == null) { + return false; + } + EmptyToken token = new EmptyToken(); + CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer) + token.getColor(game).setColor(ObjectColor.WHITE); + if (!token.hasSubtype(SubType.ZOMBIE, game)) { + token.getSubtype(game).add(0, SubType.ZOMBIE); + } + token.getManaCost().clear(); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.EMBALMED_CREATURE, token.getId(), source.getSourceId(), controller.getId())); + token.putOntoBattlefield(1, game, source.getSourceId(), controller.getId(), false, false, null); + // Probably it makes sense to remove also the Embalm ability (it's not shown on the token cards). + // Also it can never get active or? But it's not mentioned in the reminder text. + return true; } - } diff --git a/Mage/src/main/java/mage/abilities/keyword/EternalizeAbility.java b/Mage/src/main/java/mage/abilities/keyword/EternalizeAbility.java index dd46c9d9d7..c25c06d639 100644 --- a/Mage/src/main/java/mage/abilities/keyword/EternalizeAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/EternalizeAbility.java @@ -59,11 +59,11 @@ public class EternalizeAbility extends ActivatedAbilityImpl { this.timing = TimingRule.SORCERY; setRule(cost, card); } - + public EternalizeAbility(Cost cost, Card card, String rule) { this(cost, card); this.rule = rule; - } + } public EternalizeAbility(final EternalizeAbility ability) { super(ability); @@ -110,26 +110,27 @@ class EternalizeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Card card = game.getCard(source.getSourceId()); - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null && card != null) { - EmptyToken token = new EmptyToken(); - CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer) - token.getColor(game).setColor(ObjectColor.BLACK); - if (!token.hasSubtype(SubType.ZOMBIE, game)) { - token.getSubtype(game).add(0, SubType.ZOMBIE); - } - token.getManaCost().clear(); - token.removePTCDA(); - token.getPower().modifyBaseValue(4); - token.getToughness().modifyBaseValue(4); - game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ETERNALIZED_CREATURE, token.getId(), source.getSourceId(), controller.getId())); - token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId(), false, false, null); - // Probably it makes sense to remove also the Eternalize ability (it's not shown on the token cards). - // Also it can never get active or? But it's not mentioned in the reminder text. - return true; + if (card == null) { + return false; } - - return false; + Player controller = game.getPlayer(card.getOwnerId()); + if (controller == null) { + return false; + } + EmptyToken token = new EmptyToken(); + CardUtil.copyTo(token).from(card); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer) + token.getColor(game).setColor(ObjectColor.BLACK); + if (!token.hasSubtype(SubType.ZOMBIE, game)) { + token.getSubtype(game).add(0, SubType.ZOMBIE); + } + token.getManaCost().clear(); + token.removePTCDA(); + token.getPower().modifyBaseValue(4); + token.getToughness().modifyBaseValue(4); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.ETERNALIZED_CREATURE, token.getId(), source.getSourceId(), controller.getId())); + token.putOntoBattlefield(1, game, source.getSourceId(), controller.getId(), false, false, null); + // Probably it makes sense to remove also the Eternalize ability (it's not shown on the token cards). + // Also it can never get active or? But it's not mentioned in the reminder text. + return true; } - }