mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
parent
04cb20f46a
commit
263c9acfcc
3 changed files with 23 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue