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 f501e3aaeb..4ced3318ab 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 @@ -113,7 +113,7 @@ public class CardPluginImpl implements CardPlugin { JLayeredPane battlefieldPanel = (JLayeredPane) component; JComponent jPanel = ui.get("jPanel"); - Row allLands = new Row(); + Row rowAllLands = new Row(); outerLoop: // @@ -125,8 +125,8 @@ public class CardPluginImpl implements CardPlugin { int insertIndex = -1; // Find lands with the same name. - for (int i = 0, n = allLands.size(); i < n; i++) { - Stack stack = allLands.get(i); + for (int i = 0, n = rowAllLands.size(); i < n; i++) { + Stack stack = rowAllLands.get(i); MagePermanent firstPanel = stack.get(0); if (firstPanel.getOriginal().getName().equals(permanent.getOriginal().getName())) { @@ -169,19 +169,19 @@ public class CardPluginImpl implements CardPlugin { } stack.add(permanent); - allLands.add(insertIndex == -1 ? allLands.size() : insertIndex, stack); + rowAllLands.add(insertIndex == -1 ? rowAllLands.size() : insertIndex, stack); } - Row allCreatures = new Row(permanents, RowType.creature); - Row allOthers = new Row(permanents, RowType.other); - Row allAttached = new Row(permanents, RowType.attached); + Row rowAllCreatures = new Row(permanents, RowType.creature); + Row rowAllOthers = new Row(permanents, RowType.other); + Row rowAllAttached = new Row(permanents, RowType.attached); boolean othersOnTheRight = true; if (options != null && options.containsKey("nonLandPermanentsInOnePile")) { if (options.get("nonLandPermanentsInOnePile").equals("true")) { othersOnTheRight = false; - allCreatures.addAll(allOthers); - allOthers.clear(); + rowAllCreatures.addAll(rowAllOthers); + rowAllOthers.clear(); } } @@ -198,9 +198,9 @@ public class CardPluginImpl implements CardPlugin { stackSpacingX = stackVertical ? 0 : Math.round(cardWidth * STACK_SPACING_X); stackSpacingY = Math.round(cardHeight * STACK_SPACING_Y); attachmentSpacingY = Math.round(cardHeight * ATTACHMENT_SPACING_Y); - Row creatures = (Row) allCreatures.clone(); - Row lands = (Row) allLands.clone(); - Row others = (Row) allOthers.clone(); + Row creatures = (Row) rowAllCreatures.clone(); + Row lands = (Row) rowAllLands.clone(); + Row others = (Row) rowAllOthers.clone(); // Wrap all creatures and lands. wrap(creatures, rows, -1); int afterCreaturesIndex = rows.size(); @@ -291,7 +291,7 @@ public class CardPluginImpl implements CardPlugin { // we need this only for defining card size // attached permanents will be handled separately - for (Stack stack : allAttached) { + for (Stack stack : rowAllAttached) { for (MagePermanent panel : stack) { panel.setCardBounds(0, 0, cardWidth, cardHeight); } @@ -380,8 +380,7 @@ public class CardPluginImpl implements CardPlugin { case other: return !CardUtil.isLand(card) && !CardUtil.isCreature(card); case attached: - return card.getOriginalPermanent().isAttachedTo() - && !card.getOriginalPermanent().getSubTypes().contains("Curse"); + return card.getOriginalPermanent().isAttachedToPermanent(); default: throw new RuntimeException("Unhandled type: " + this); } @@ -401,18 +400,18 @@ public class CardPluginImpl implements CardPlugin { } private void addAll(Collection permanents, RowType type) { - for (MagePermanent panel : permanents) { - if (!type.isType(panel)) { + for (MagePermanent permanent : permanents) { + if (!type.isType(permanent)) { continue; } // all attached permanents are grouped separately later - if (!type.equals(RowType.attached) && RowType.attached.isType(panel)) { + if (!type.equals(RowType.attached) && RowType.attached.isType(permanent)) { continue; } Stack stack = new Stack(); - stack.add(panel); - if (panel.getOriginalPermanent().getAttachments() != null) { - stack.setMaxAttachedCount(panel.getOriginalPermanent().getAttachments().size()); + stack.add(permanent); + if (permanent.getOriginalPermanent().getAttachments() != null) { + stack.setMaxAttachedCount(permanent.getOriginalPermanent().getAttachments().size()); } add(stack); } diff --git a/Mage.Common/src/mage/view/PermanentView.java b/Mage.Common/src/mage/view/PermanentView.java index c7a4e3741f..80451c0250 100644 --- a/Mage.Common/src/mage/view/PermanentView.java +++ b/Mage.Common/src/mage/view/PermanentView.java @@ -59,6 +59,7 @@ public class PermanentView extends CardView { private final UUID attachedTo; private final boolean morphed; private final boolean manifested; + private final boolean attachedToPermanent; public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) { super(permanent, null, permanent.getControllerId().equals(createdForPlayerId)); @@ -143,7 +144,13 @@ public class PermanentView extends CardView { " A face-down card can also be turned face up for its morph cost."); } } - } + } + // determines if shown in it's own column + if (permanent.getAttachedTo() != null) { + attachedToPermanent = game.getPermanent(permanent.getAttachedTo()) != null; + } else { + attachedToPermanent = false; + } } public boolean isTapped() { @@ -198,6 +205,10 @@ public class PermanentView extends CardView { return attachedTo != null; } + public boolean isAttachedToPermanent() { + return attachedToPermanent; + } + public boolean isMorphed() { return morphed; }