diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java b/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java index 315610c6142..ad6ac0bffef 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java @@ -157,6 +157,7 @@ public class CardPluginImpl implements CardPlugin { Row allCreatures = new Row(permanents, RowType.creature); Row allOthers = new Row(permanents, RowType.other); + Row allAttached = new Row(permanents, RowType.attached); boolean othersOnTheRight = true; if (options != null && options.containsKey("nonLandPermanentsInOnePile")) { @@ -268,6 +269,14 @@ public class CardPluginImpl implements CardPlugin { y = rowBottom; } + // we need this only for defining card size + // attached permanents will be handled separately + for (Stack stack : allAttached) { + for (MagePermanent panel : stack) { + panel.setCardBounds(0, 0, cardWidth, cardHeight); + } + } + return y; } @@ -340,7 +349,7 @@ public class CardPluginImpl implements CardPlugin { } private static enum RowType { - land, creature, other; + land, creature, other, attached; public boolean isType(MagePermanent card) { switch (this) { @@ -350,6 +359,8 @@ public class CardPluginImpl implements CardPlugin { return CardUtil.isCreature(card); case other: return !CardUtil.isLand(card) && !CardUtil.isCreature(card); + case attached: + return card.getOriginalPermanent().isAttachedTo(); default: throw new RuntimeException("Unhandled type: " + this); } @@ -373,6 +384,10 @@ public class CardPluginImpl implements CardPlugin { if (!type.isType(panel)) { continue; } + // all attached permanents are grouped separately later + if (!type.equals(RowType.attached) && RowType.attached.isType(panel)) { + continue; + } Stack stack = new Stack(); stack.add(panel); if (panel.getOriginalPermanent().getAttachments() != null) { diff --git a/Mage.Common/src/mage/view/PermanentView.java b/Mage.Common/src/mage/view/PermanentView.java index f9e4efd2a26..ea7dba67855 100644 --- a/Mage.Common/src/mage/view/PermanentView.java +++ b/Mage.Common/src/mage/view/PermanentView.java @@ -28,9 +28,6 @@ package mage.view; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.TurnFaceUpAbility; import mage.abilities.common.TurnedFaceUpTriggeredAbility; @@ -38,10 +35,13 @@ import mage.cards.Card; import mage.constants.Rarity; import mage.game.Game; import mage.game.permanent.Permanent; -import mage.game.permanent.PermanentCard; import mage.game.permanent.PermanentToken; import mage.players.Player; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -59,6 +59,7 @@ public class PermanentView extends CardView { private final boolean copy; private final String nameOwner; // only filled if != controller private final boolean controlled; + private UUID attachedTo; public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) { super(permanent, null, permanent.getControllerId().equals(createdForPlayerId)); @@ -73,6 +74,7 @@ public class PermanentView extends CardView { attachments = new ArrayList<>(); attachments.addAll(permanent.getAttachments()); } + this.attachedTo = permanent.getAttachedTo(); if (isToken()) { original = new CardView(((PermanentToken)permanent).getToken()); original.expansionSetCode = permanent.getExpansionSetCode(); @@ -179,5 +181,12 @@ public class PermanentView extends CardView { public boolean isControlled() { return controlled; } - + + public UUID getAttachedTo() { + return attachedTo; + } + + public boolean isAttachedTo() { + return attachedTo != null; + } }