From 0b0ff83c1f3e0f0afa7f2b7fc07526331b94a645 Mon Sep 17 00:00:00 2001 From: xenohedron Date: Fri, 18 Aug 2023 21:53:57 -0400 Subject: [PATCH] improve comments in TokenImpl messy aura target-searching code --- .../src/main/java/mage/game/permanent/token/TokenImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java b/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java index ecfe8d28c4e..7763f3d48c3 100644 --- a/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java +++ b/Mage/src/main/java/mage/game/permanent/token/TokenImpl.java @@ -263,7 +263,7 @@ public abstract class TokenImpl extends MageObjectImpl implements Token { Token token = entry.getKey(); int amount = entry.getValue(); - // check if token needs to be attached to something + // check if token needs to be attached to a specific object (e.g. Estrid the Masked, Role Token) Permanent permanentAttachedTo; if (attachedTo != null) { permanentAttachedTo = game.getPermanent(attachedTo); @@ -332,6 +332,8 @@ public abstract class TokenImpl extends MageObjectImpl implements Token { } // if token was created (not a spell copy) handle auras coming into the battlefield + // that must determine what to enchant + // see #9583 for the root cause issue of why this convoluted searching is necessary // code blindly copied from CopyPermanentEffect // TODO: clean this up -- half the comments make no sense in the context of creating a token if (created && permanent.getSubtype().contains(SubType.AURA) && attachedTo == null) { @@ -390,8 +392,9 @@ public abstract class TokenImpl extends MageObjectImpl implements Token { targetPlayer.addAttachment(permanent.getId(), source, game); } } - // end of aura code : just remove this line if everything works out well + // end of messy target-groping code to handle auras + // this section is for tokens created attached to a specific known object if (permanentAttachedTo != null) { if (permanent.hasSubtype(SubType.AURA, game)) { permanent.getAbilities().get(0).getTargets().get(0).add(permanentAttachedTo.getId(), game);