* UI: fixed duplicated names in related objects list on card hint;

This commit is contained in:
Oleg Agafonov 2019-06-03 16:35:17 +04:00
parent 728490878e
commit eb6478cd59
2 changed files with 16 additions and 16 deletions

View file

@ -1,11 +1,5 @@
package mage.view; 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.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
@ -20,8 +14,9 @@ import mage.game.permanent.PermanentToken;
import mage.target.targetpointer.TargetPointer; import mage.target.targetpointer.TargetPointer;
import mage.util.GameLog; import mage.util.GameLog;
import java.util.*;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class CardsView extends LinkedHashMap<UUID, CardView> { public class CardsView extends LinkedHashMap<UUID, CardView> {
@ -91,11 +86,11 @@ public class CardsView extends LinkedHashMap<UUID, CardView> {
// throw new IllegalArgumentException("Source card for emblem not found."); // throw new IllegalArgumentException("Source card for emblem not found.");
// } // }
abilityView = new AbilityView(ability, sourceObject.getName(), new CardView(new EmblemView((Emblem) sourceObject))); 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()); // abilityView.setExpansionSetCode(sourceCard.getExpansionSetCode());
} else if (sourceObject instanceof Plane) { } else if (sourceObject instanceof Plane) {
abilityView = new AbilityView(ability, sourceObject.getName(), new CardView(new PlaneView((Plane) sourceObject))); abilityView = new AbilityView(ability, sourceObject.getName(), new CardView(new PlaneView((Plane) sourceObject)));
abilityView.setName(((Plane) sourceObject).getName()); abilityView.setName(sourceObject.getName());
} }
break; break;
} }
@ -131,7 +126,10 @@ public class CardsView extends LinkedHashMap<UUID, CardView> {
if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) { if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) {
continue; continue;
} }
names.add(GameLog.getColoredObjectIdNameForTooltip(mageObject)); String newName = GameLog.getColoredObjectIdNameForTooltip(mageObject);
if (!names.contains(newName)) {
names.add(newName);
}
} }
} }
if (!names.isEmpty()) { if (!names.isEmpty()) {

View file

@ -1,9 +1,5 @@
package mage.view; package mage.view;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.Modes; import mage.abilities.Modes;
@ -18,8 +14,11 @@ import mage.target.targetpointer.FixedTarget;
import mage.target.targetpointer.TargetPointer; import mage.target.targetpointer.TargetPointer;
import mage.util.GameLog; import mage.util.GameLog;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class StackAbilityView extends CardView { public class StackAbilityView extends CardView {
@ -94,7 +93,10 @@ public class StackAbilityView extends CardView {
if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) { if ((mageObject instanceof Card) && ((Card) mageObject).isFaceDown(game)) {
continue; continue;
} }
names.add(GameLog.getColoredObjectIdNameForTooltip(mageObject)); String newName = GameLog.getColoredObjectIdNameForTooltip(mageObject);
if (!names.contains(newName)) {
names.add(newName);
}
} }
} }