From eb6478cd599a79ba2705ce9f707cfd36f9a9b7df Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Mon, 3 Jun 2019 16:35:17 +0400 Subject: [PATCH] * UI: fixed duplicated names in related objects list on card hint; --- .../src/main/java/mage/view/CardsView.java | 18 ++++++++---------- .../main/java/mage/view/StackAbilityView.java | 14 ++++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Mage.Common/src/main/java/mage/view/CardsView.java b/Mage.Common/src/main/java/mage/view/CardsView.java index 2a1264f0ce..1e7ffec266 100644 --- a/Mage.Common/src/main/java/mage/view/CardsView.java +++ b/Mage.Common/src/main/java/mage/view/CardsView.java @@ -1,11 +1,5 @@ - package mage.view; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.Effect; @@ -20,8 +14,9 @@ import mage.game.permanent.PermanentToken; import mage.target.targetpointer.TargetPointer; import mage.util.GameLog; +import java.util.*; + /** - * * @author BetaSteward_at_googlemail.com */ public class CardsView extends LinkedHashMap { @@ -91,11 +86,11 @@ public class CardsView extends LinkedHashMap { // throw new IllegalArgumentException("Source card for emblem not found."); // } abilityView = new AbilityView(ability, sourceObject.getName(), new CardView(new EmblemView((Emblem) sourceObject))); - abilityView.setName(((Emblem) sourceObject).getName()); + abilityView.setName(sourceObject.getName()); // abilityView.setExpansionSetCode(sourceCard.getExpansionSetCode()); } else if (sourceObject instanceof Plane) { abilityView = new AbilityView(ability, sourceObject.getName(), new CardView(new PlaneView((Plane) sourceObject))); - abilityView.setName(((Plane) sourceObject).getName()); + abilityView.setName(sourceObject.getName()); } break; } @@ -131,7 +126,10 @@ public class CardsView extends LinkedHashMap { if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) { continue; } - names.add(GameLog.getColoredObjectIdNameForTooltip(mageObject)); + String newName = GameLog.getColoredObjectIdNameForTooltip(mageObject); + if (!names.contains(newName)) { + names.add(newName); + } } } if (!names.isEmpty()) { diff --git a/Mage.Common/src/main/java/mage/view/StackAbilityView.java b/Mage.Common/src/main/java/mage/view/StackAbilityView.java index 7ae1d5dcf4..b4e1e2539f 100644 --- a/Mage.Common/src/main/java/mage/view/StackAbilityView.java +++ b/Mage.Common/src/main/java/mage/view/StackAbilityView.java @@ -1,9 +1,5 @@ - package mage.view; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; import mage.MageObject; import mage.abilities.Mode; import mage.abilities.Modes; @@ -18,8 +14,11 @@ import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.TargetPointer; import mage.util.GameLog; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com */ public class StackAbilityView extends CardView { @@ -94,7 +93,10 @@ public class StackAbilityView extends CardView { if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) { continue; } - names.add(GameLog.getColoredObjectIdNameForTooltip(mageObject)); + String newName = GameLog.getColoredObjectIdNameForTooltip(mageObject); + if (!names.contains(newName)) { + names.add(newName); + } } }