mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
parent
fee866d4f0
commit
78a2a5c712
3 changed files with 36 additions and 10 deletions
|
|
@ -175,6 +175,9 @@ class LyndeCheerfulTormentorAttachCurseEffect extends OneShotEffect {
|
||||||
if (opponent != null) {
|
if (opponent != null) {
|
||||||
controller.removeAttachment(curse, source, game);
|
controller.removeAttachment(curse, source, game);
|
||||||
opponent.addAttachment(curse.getId(), source, game);
|
opponent.addAttachment(curse.getId(), source, game);
|
||||||
|
|
||||||
|
game.informPlayers(
|
||||||
|
curse.getLogName() + " is now attached to " + opponent.getLogName() + ".");
|
||||||
controller.drawCards(2, source, game);
|
controller.drawCards(2, source, game);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,12 +130,15 @@ class MaddeningHexEffect extends OneShotEffect {
|
||||||
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
Set<UUID> opponents = game.getOpponents(source.getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
opponents.remove(player.getId());
|
opponents.remove(player.getId());
|
||||||
|
player.removeAttachment(permanent, source, game);
|
||||||
}
|
}
|
||||||
Player opponent = game.getPlayer(RandomUtil.randomFromCollection(opponents));
|
Player opponent = game.getPlayer(RandomUtil.randomFromCollection(opponents));
|
||||||
if (opponent == null) {
|
if (opponent == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
opponent.addAttachment(permanent.getId(), source, game);
|
opponent.addAttachment(permanent.getId(), source, game);
|
||||||
|
|
||||||
|
game.informPlayers(permanent.getLogName() + " is now attached to " + opponent.getLogName() + ".");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -844,11 +844,12 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
@Override
|
@Override
|
||||||
public void unattach(Game game) {
|
public void unattach(Game game) {
|
||||||
this.attachedTo = null;
|
this.attachedTo = null;
|
||||||
this.addInfo("attachedToCard", null, game);
|
this.addInfo("attachedTo", null, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attachTo(UUID attachToObjectId, Ability source, Game game) {
|
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)) {
|
if (this.attachedTo != null && !Objects.equals(this.attachedTo, attachToObjectId)) {
|
||||||
Permanent attachedToUntilNowObject = game.getPermanent(this.attachedTo);
|
Permanent attachedToUntilNowObject = game.getPermanent(this.attachedTo);
|
||||||
if (attachedToUntilNowObject != null) {
|
if (attachedToUntilNowObject != null) {
|
||||||
|
|
@ -857,6 +858,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
Card attachedToUntilNowCard = game.getCard(this.attachedTo);
|
Card attachedToUntilNowCard = game.getCard(this.attachedTo);
|
||||||
if (attachedToUntilNowCard != null) {
|
if (attachedToUntilNowCard != null) {
|
||||||
attachedToUntilNowCard.removeAttachment(this.objectId, source, game);
|
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
|
// Reset "attached to" tooltip before potentially adding it
|
||||||
return;
|
this.addInfo("attachedTo", null, game);
|
||||||
}
|
if (this.attachedTo != null) {
|
||||||
if (!getSpellAbility().getTargets().isEmpty() && (getSpellAbility().getTargets().get(0) instanceof TargetCard)) {
|
Permanent attachedToPerm = game.getPermanent(this.getAttachedTo());
|
||||||
Card attachedToCard = game.getCard(this.getAttachedTo());
|
// If what this permanent is attached to isn't also a permenent, such as a
|
||||||
if (attachedToCard != null) {
|
// player or card in graveyard, it is important to mention what it is attached
|
||||||
// Because cards are not on the battlefield, the relation has to be shown in the card tooltip (e.g. the enchanted card in graveyard)
|
// to in the tooltip. The rules let you attach a permanent to any kind of object
|
||||||
this.addInfo("attachedToCard", CardUtil.addToolTipMarkTags("Enchanted card: " + attachedToCard.getIdName()), game);
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue