Added attachment controller info (#10440)

Fixes magefree/mage#9971
This commit is contained in:
Alexander Novotny 2023-06-08 18:34:26 -07:00 committed by GitHub
parent a0f8a42699
commit 76f30b3046
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View file

@ -334,6 +334,9 @@ public final class GuiDisplayUtil {
buffer.append("[only controlled] "); buffer.append("[only controlled] ");
} }
} }
if (card instanceof PermanentView && ((PermanentView) card).isAttachedToDifferentlyControlledPermanent()) {
buffer.append('(').append(((PermanentView) card).getNameController()).append(") ");
}
if (card.getMageObjectType() != MageObjectType.NULL) { if (card.getMageObjectType() != MageObjectType.NULL) {
buffer.append(card.getMageObjectType().toString()); buffer.append(card.getMageObjectType().toString());
} }

View file

@ -29,11 +29,14 @@ public class PermanentView extends CardView {
private final CardView original; // original card before transforms and modifications (null for opponents face down cards) private final CardView original; // original card before transforms and modifications (null for opponents face down cards)
private final boolean copy; private final boolean copy;
private final String nameOwner; // only filled if != controller private final String nameOwner; // only filled if != controller
private final String nameController;
private final boolean controlled; private final boolean controlled;
private final UUID attachedTo; private final UUID attachedTo;
private final boolean morphed; private final boolean morphed;
private final boolean manifested; private final boolean manifested;
private final boolean attachedToPermanent; private final boolean attachedToPermanent;
// If this card is attached to a permanent which is controlled by a player other than the one which controls this permanent
private final boolean attachedControllerDiffers;
public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) { public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) {
super(permanent, game, permanent.getControllerId() != null && permanent.getControllerId().equals(createdForPlayerId)); super(permanent, game, permanent.getControllerId() != null && permanent.getControllerId().equals(createdForPlayerId));
@ -89,6 +92,13 @@ public class PermanentView extends CardView {
this.nameOwner = ""; this.nameOwner = "";
} }
Player controller = game.getPlayer(permanent.getControllerId());
if (controller != null) {
nameController = controller.getName();
} else {
nameController = "";
}
// add info for face down permanents // add info for face down permanents
if (permanent.isFaceDown(game) && card != null) { if (permanent.isFaceDown(game) && card != null) {
if (showFaceDownInfo) { if (showFaceDownInfo) {
@ -116,10 +126,13 @@ public class PermanentView extends CardView {
} }
} }
// determines if shown in it's own column // determines if shown in it's own column
if (permanent.getAttachedTo() != null) { Permanent attachment = game.getPermanent(permanent.getAttachedTo());
attachedToPermanent = game.getPermanent(permanent.getAttachedTo()) != null; if (attachment != null) {
attachedToPermanent = true;
attachedControllerDiffers = !attachment.getControllerId().equals(permanent.getControllerId());
} else { } else {
attachedToPermanent = false; attachedToPermanent = false;
attachedControllerDiffers = false;
} }
} }
@ -163,6 +176,10 @@ public class PermanentView extends CardView {
return nameOwner; return nameOwner;
} }
public String getNameController() {
return nameController;
}
public boolean isControlled() { public boolean isControlled() {
return controlled; return controlled;
} }
@ -179,6 +196,10 @@ public class PermanentView extends CardView {
return attachedToPermanent; return attachedToPermanent;
} }
public boolean isAttachedToDifferentlyControlledPermanent() {
return attachedControllerDiffers;
}
public boolean isMorphed() { public boolean isMorphed() {
return morphed; return morphed;
} }