From f46ac4c5ee10dba9ebfe0fc026c739016185f01c Mon Sep 17 00:00:00 2001 From: xenohedron Date: Sat, 18 Nov 2023 22:39:00 -0500 Subject: [PATCH] fix LoseLifeControllerAttachedEffect resolves #11421 --- .../LoseLifeControllerAttachedEffect.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeControllerAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeControllerAttachedEffect.java index e1b888b7bf2..21c7fbca1bb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/LoseLifeControllerAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/LoseLifeControllerAttachedEffect.java @@ -1,4 +1,3 @@ - package mage.abilities.effects.common; import mage.abilities.Ability; @@ -38,24 +37,21 @@ public class LoseLifeControllerAttachedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - if (enchantment == null) { - enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); + Permanent attachment = source.getSourcePermanentOrLKI(game); + if (attachment == null || attachment.getAttachedTo() == null) { + return false; } - if (enchantment != null && enchantment.getAttachedTo() != null) { - Permanent creature = game.getPermanent(enchantment.getAttachedTo()); - if (creature == null) { - creature = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - } - if (creature != null) { - Player player = game.getPlayer(creature.getControllerId()); - if (player != null) { - player.loseLife(amount.calculate(game, source, this), game, source, false); - return true; - } - } + Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(), + Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter()); + if (attachedTo == null) { + return false; } - return false; + Player player = game.getPlayer(attachedTo.getControllerId()); + if (player == null) { + return false; + } + player.loseLife(amount.calculate(game, source, this), game, source, false); + return true; } private void setText() {