This commit is contained in:
Jeff 2019-03-21 16:21:46 -05:00
parent 04cb20f46a
commit 263c9acfcc
3 changed files with 23 additions and 9 deletions

View file

@ -35,13 +35,17 @@ public class ControlEnchantedEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
if (enchantment != null
&& enchantment.getAttachedTo() != null) {
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
if (permanent != null) {
switch (layer) {
case ControlChangingEffects_2:
if (sublayer == SubLayer.NA) {
permanent.changeControllerId(enchantment.getControllerId(), game);
permanent.getAbilities().forEach((ability) -> {
ability.setControllerId(enchantment.getControllerId());
});
}
break;
}

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common.continuous;
import java.util.UUID;
@ -98,12 +97,14 @@ public class GainControlTargetEffect extends ContinuousEffectImpl {
}
}
}
if (!targetStillExists) {
// no valid target exists, effect can be discarded
// no valid target exists and the controller is no longer in the game, effect can be discarded
if (!targetStillExists
|| !controller.isInGame()) {
discard();
}
return true;
}
discard(); // controller no longer exists
return false;
}