diff --git a/Mage.Sets/src/mage/cards/l/LyndeCheerfulTormentor.java b/Mage.Sets/src/mage/cards/l/LyndeCheerfulTormentor.java index ea3908500d0..bb8b902b95f 100644 --- a/Mage.Sets/src/mage/cards/l/LyndeCheerfulTormentor.java +++ b/Mage.Sets/src/mage/cards/l/LyndeCheerfulTormentor.java @@ -175,6 +175,9 @@ class LyndeCheerfulTormentorAttachCurseEffect extends OneShotEffect { if (opponent != null) { controller.removeAttachment(curse, source, game); opponent.addAttachment(curse.getId(), source, game); + + game.informPlayers( + curse.getLogName() + " is now attached to " + opponent.getLogName() + "."); controller.drawCards(2, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/m/MaddeningHex.java b/Mage.Sets/src/mage/cards/m/MaddeningHex.java index 430315b6bdc..d3276696b03 100644 --- a/Mage.Sets/src/mage/cards/m/MaddeningHex.java +++ b/Mage.Sets/src/mage/cards/m/MaddeningHex.java @@ -130,12 +130,15 @@ class MaddeningHexEffect extends OneShotEffect { Set opponents = game.getOpponents(source.getControllerId()); if (player != null) { opponents.remove(player.getId()); + player.removeAttachment(permanent, source, game); } Player opponent = game.getPlayer(RandomUtil.randomFromCollection(opponents)); if (opponent == null) { return true; } opponent.addAttachment(permanent.getId(), source, game); + + game.informPlayers(permanent.getLogName() + " is now attached to " + opponent.getLogName() + "."); return true; } } diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 8cdc8562438..2187ddd7ffe 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -844,11 +844,12 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { @Override public void unattach(Game game) { this.attachedTo = null; - this.addInfo("attachedToCard", null, game); + this.addInfo("attachedTo", null, game); } @Override public void attachTo(UUID attachToObjectId, Ability source, Game game) { + // 701.3a - Permanents can be attached to an object or player if (this.attachedTo != null && !Objects.equals(this.attachedTo, attachToObjectId)) { Permanent attachedToUntilNowObject = game.getPermanent(this.attachedTo); if (attachedToUntilNowObject != null) { @@ -857,6 +858,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { Card attachedToUntilNowCard = game.getCard(this.attachedTo); if (attachedToUntilNowCard != null) { attachedToUntilNowCard.removeAttachment(this.objectId, source, game); + } else { + Player attachedToUntilNowPlayer = game.getPlayer(this.attachedTo); + if (attachedToUntilNowPlayer != null) { + attachedToUntilNowPlayer.removeAttachment(this, source, game); + } } } @@ -875,15 +881,29 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } } } - if (getSpellAbility() == null) { - // Can happen e.g. for Token Equipments like Stoneforged Blade - return; - } - if (!getSpellAbility().getTargets().isEmpty() && (getSpellAbility().getTargets().get(0) instanceof TargetCard)) { - Card attachedToCard = game.getCard(this.getAttachedTo()); - if (attachedToCard != null) { - // Because cards are not on the battlefield, the relation has to be shown in the card tooltip (e.g. the enchanted card in graveyard) - this.addInfo("attachedToCard", CardUtil.addToolTipMarkTags("Enchanted card: " + attachedToCard.getIdName()), game); + + // Reset "attached to" tooltip before potentially adding it + this.addInfo("attachedTo", null, game); + if (this.attachedTo != null) { + Permanent attachedToPerm = game.getPermanent(this.getAttachedTo()); + // If what this permanent is attached to isn't also a permenent, such as a + // player or card in graveyard, it is important to mention what it is attached + // to in the tooltip. The rules let you attach a permanent to any kind of object + // or player, although currently the only objects it's possible to attach a + // permanent to are another permanent or a card. But to help future-proof this, + // we'll generalise to objects. + if (attachedToPerm == null) { + MageObject attachedToObject = game.getObject(this.getAttachedTo()); + if (attachedToObject != null) { + this.addInfo("attachedTo", + CardUtil.addToolTipMarkTags("Attached to: " + attachedToObject.getIdName()), game); + } else { + Player attachedToPlayer = game.getPlayer(this.getAttachedTo()); + if (attachedToPlayer != null) { + this.addInfo("attachedTo", + CardUtil.addToolTipMarkTags("Attached to: " + attachedToPlayer.getName()), game); + } + } } } }