diff --git a/Mage.Sets/src/mage/cards/c/CrownOfDoom.java b/Mage.Sets/src/mage/cards/c/CrownOfDoom.java index c5765ad727d..6adeceba04a 100644 --- a/Mage.Sets/src/mage/cards/c/CrownOfDoom.java +++ b/Mage.Sets/src/mage/cards/c/CrownOfDoom.java @@ -1,4 +1,3 @@ - package mage.cards.c; import java.util.Objects; @@ -44,11 +43,20 @@ public final class CrownOfDoom extends CardImpl { // Whenever a creature attacks you or a planeswalker you control, it gets +2/+0 until end of turn. Effect effect = new BoostTargetEffect(2, 0, Duration.EndOfTurn); effect.setText("it gets +2/+0 until end of turn"); - this.addAbility(new AttacksAllTriggeredAbility(effect, false, StaticFilters.FILTER_PERMANENT_CREATURE, SetTargetPointer.PERMANENT, true)); + this.addAbility(new AttacksAllTriggeredAbility( + effect, + false, + StaticFilters.FILTER_PERMANENT_CREATURE, + SetTargetPointer.PERMANENT, + true)); //TODO: Make ability properly copiable // {2}: Target player other than Crown of Doom's owner gains control of it. Activate this ability only during your turn. - Ability ability = new ActivateIfConditionActivatedAbility(Zone.BATTLEFIELD, new CrownOfDoomEffect(), new ManaCostsImpl("{2}"), MyTurnCondition.instance); + Ability ability = new ActivateIfConditionActivatedAbility( + Zone.BATTLEFIELD, + new CrownOfDoomEffect(), + new ManaCostsImpl("{2}"), + MyTurnCondition.instance); ability.addTarget(new TargetPlayer(1, 1, false, filter)); this.addAbility(ability); } @@ -104,8 +112,9 @@ class CrownOfDoomEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player newController = game.getPlayer(getTargetPointer().getFirst(game, source)); - if (controller != null && newController != null && !Objects.equals(controller.getId(), newController.getId())) { - // Duration.Custom = effect ends if Artifact leaves the current zone (battlefield) + if (controller != null + && newController != null + && !Objects.equals(controller.getId(), newController.getId())) { ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, newController.getId()); effect.setTargetPointer(new FixedTarget(source.getSourceId())); game.addEffect(effect, source); diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/ControlEnchantedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/ControlEnchantedEffect.java index 44074e0028f..3b8d579a0c7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/ControlEnchantedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/ControlEnchantedEffect.java @@ -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; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlTargetEffect.java index 8e4d51164b1..129c58657ac 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/GainControlTargetEffect.java @@ -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; }