diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java index f6a60065d1..f2f2d7c790 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java @@ -194,30 +194,30 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti } }); } + if (!newGameCard.isAbility()) { + // panel to show counters on the card + counterPanel = new JPanel(); + counterPanel.setLayout(null); + counterPanel.setOpaque(false); + add(counterPanel); - // panel to show counters on the card - counterPanel = new JPanel(); - counterPanel.setLayout(null); - counterPanel.setOpaque(false); - add(counterPanel); + plusCounterLabel = new JLabel(""); + plusCounterLabel.setToolTipText("+1/+1"); + counterPanel.add(plusCounterLabel); - plusCounterLabel = new JLabel(""); - plusCounterLabel.setToolTipText("+1/+1"); - counterPanel.add(plusCounterLabel); + minusCounterLabel = new JLabel(""); + minusCounterLabel.setToolTipText("-1/-1"); + counterPanel.add(minusCounterLabel); - minusCounterLabel = new JLabel(""); - minusCounterLabel.setToolTipText("-1/-1"); - counterPanel.add(minusCounterLabel); + loyaltyCounterLabel = new JLabel(""); + loyaltyCounterLabel.setToolTipText("loyalty"); + counterPanel.add(loyaltyCounterLabel); - loyaltyCounterLabel = new JLabel(""); - loyaltyCounterLabel.setToolTipText("loyalty"); - counterPanel.add(loyaltyCounterLabel); - - otherCounterLabel = new JLabel(""); - counterPanel.add(otherCounterLabel); - - counterPanel.setVisible(false); + otherCounterLabel = new JLabel(""); + counterPanel.add(otherCounterLabel); + counterPanel.setVisible(false); + } if (newGameCard.isAbility()) { if (AbilityType.TRIGGERED.equals(newGameCard.getAbilityType())) { setTypeIcon(ImageManagerImpl.getInstance().getTriggeredAbilityImage(),"Triggered Ability"); @@ -841,7 +841,14 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti } } - + if (counterPanel != null) { + updateCounters(card); + } + + repaint(); + } + + private void updateCounters(CardView card) { if (card.getCounters() != null && !card.getCounters().isEmpty()) { String name = ""; if (lastCardWidth != cardWidth) { @@ -890,8 +897,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti otherCounterLabel.setVisible(true); } } - } - + } + counterPanel.setVisible(true); } else { plusCounterLabel.setVisible(false); @@ -899,8 +906,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti loyaltyCounterLabel.setVisible(false); otherCounterLabel.setVisible(false); counterPanel.setVisible(false); - } - repaint(); + } + } private static ImageIcon getCounterImageWithAmount(int amount, BufferedImage image, int cardWidth) { @@ -1064,7 +1071,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti } } - return sbType.toString(); + return sbType.toString().trim(); } protected final String getText(String cardType, CardView card) { diff --git a/Mage.Common/src/mage/view/CardsView.java b/Mage.Common/src/mage/view/CardsView.java index 7285357e28..6f61d93769 100644 --- a/Mage.Common/src/mage/view/CardsView.java +++ b/Mage.Common/src/mage/view/CardsView.java @@ -68,27 +68,34 @@ public class CardsView extends LinkedHashMap<UUID, CardView> { for ( Ability ability : abilities ) { MageObject sourceObject = null; AbilityView abilityView = null; + boolean isCard = false; + boolean isPermanent = false; switch ( ability.getZone() ) { case ALL: case EXILED: case GRAVEYARD: sourceObject = game.getCard(ability.getSourceId()); + isCard = true; break; case BATTLEFIELD: sourceObject = game.getPermanent(ability.getSourceId()); if (sourceObject == null) { sourceObject = (Permanent)game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD); } + isPermanent = true; break; case STACK: sourceObject = game.getObject(ability.getSourceId()); + if (sourceObject instanceof Card) { + isCard = true; + } break; case COMMAND: sourceObject = game.getObject(ability.getSourceId()); - if (sourceObject instanceof Emblem) { + if (sourceObject instanceof Emblem) { Card planeswalkerCard = game.getCard(((Emblem)sourceObject).getSourceId()); if (planeswalkerCard != null) { - abilityView = new AbilityView(ability, "Emblem " + planeswalkerCard.getName(), new CardView(sourceObject)); + abilityView = new AbilityView(ability, "Emblem " + planeswalkerCard.getName(), new CardView(new EmblemView((Emblem)sourceObject, planeswalkerCard))); abilityView.setName("Emblem " + planeswalkerCard.getName()); abilityView.setExpansionSetCode(planeswalkerCard.getExpansionSetCode()); } else { @@ -99,7 +106,15 @@ public class CardsView extends LinkedHashMap<UUID, CardView> { } if (sourceObject != null) { if (abilityView == null) { - abilityView = new AbilityView(ability, sourceObject.getLogName(), new CardView(sourceObject)); + CardView sourceCardView; + if (isPermanent) { + sourceCardView = new CardView((Permanent)sourceObject); + } else if (isCard) { + sourceCardView = new CardView((Card)sourceObject); + } else { + sourceCardView = new CardView(sourceObject); + } + abilityView = new AbilityView(ability, sourceObject.getLogName(), sourceCardView); } if (ability.getTargets().size() > 0) { abilityView.setTargets(ability.getTargets());