From 8b67be6e658108572effe5f748e08dd0bea5a0ba Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 12 Sep 2013 12:34:05 +0200 Subject: [PATCH] Cards of libraries for searches are shown ordered by name now to make it easier to find specific cards (#326). --- .../mage/target/common/TargetCardInLibrary.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Mage/src/mage/target/common/TargetCardInLibrary.java b/Mage/src/mage/target/common/TargetCardInLibrary.java index 82415cad9cc..caadc69d26b 100644 --- a/Mage/src/mage/target/common/TargetCardInLibrary.java +++ b/Mage/src/mage/target/common/TargetCardInLibrary.java @@ -28,7 +28,11 @@ package mage.target.common; +import java.util.Collections; +import java.util.Comparator; import java.util.List; +import java.util.Set; +import java.util.TreeSet; import mage.constants.Outcome; import mage.constants.Zone; import mage.abilities.Ability; @@ -85,7 +89,7 @@ public class TargetCardInLibrary extends TargetCard { int maxCards = Math.min(cardLimit.intValue(), targetPlayer.getLibrary().size()); cards = targetPlayer.getLibrary().getTopCards(game, maxCards); } - + Collections.sort(cards, new CardNameComparator()); while (!isChosen() && !doneChosing()) { chosen = targets.size() >= minNumberOfTargets; if (!player.choose(outcome, new CardsImpl(Zone.LIBRARY, cards), this, game)) { @@ -121,3 +125,11 @@ public class TargetCardInLibrary extends TargetCard { } + +class CardNameComparator implements Comparator { + + @Override + public int compare(Card o1, Card o2) { + return o1.getName().compareTo(o2.getName()); + } +}