mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Let preferred art be respected again for unique cards only list
This commit is contained in:
@@ -79,12 +79,17 @@ public final class CardDb implements ICardDatabase {
|
||||
this.isFoil = isFoil;
|
||||
}
|
||||
|
||||
public static CardRequest fromString(String name) {
|
||||
public static CardRequest fromString(String name) {
|
||||
boolean isFoil = name.endsWith(foilSuffix);
|
||||
if (isFoil) {
|
||||
name = name.substring(0, name.length() - foilSuffix.length());
|
||||
}
|
||||
|
||||
String preferredArt = artPrefs.get(name);
|
||||
if (preferredArt != null) { //account for preferred art if needed
|
||||
name += NameSetSeparator + preferredArt;
|
||||
}
|
||||
|
||||
String[] nameParts = TextUtil.split(name, NameSetSeparator);
|
||||
|
||||
int setPos = nameParts.length >= 2 && !StringUtils.isNumeric(nameParts[1]) ? 1 : -1;
|
||||
@@ -189,10 +194,6 @@ public final class CardDb implements ICardDatabase {
|
||||
|
||||
@Override
|
||||
public PaperCard getCard(String cardName) {
|
||||
String preferredArt = artPrefs.get(cardName);
|
||||
if (preferredArt != null) { //account for preferred art if needed
|
||||
cardName += NameSetSeparator + preferredArt;
|
||||
}
|
||||
CardRequest request = CardRequest.fromString(cardName);
|
||||
return tryGetCard(request);
|
||||
}
|
||||
@@ -217,10 +218,10 @@ public final class CardDb implements ICardDatabase {
|
||||
}
|
||||
return tryGetCard(request);
|
||||
}
|
||||
|
||||
|
||||
private PaperCard tryGetCard(CardRequest request) {
|
||||
Collection<PaperCard> cards = allCardsByName.get(request.cardName);
|
||||
if (null == cards) { return null; }
|
||||
if (cards == null) { return null; }
|
||||
|
||||
PaperCard result = null;
|
||||
|
||||
@@ -228,18 +229,23 @@ public final class CardDb implements ICardDatabase {
|
||||
if (reqEdition != null && !editions.contains(reqEdition)) {
|
||||
CardEdition edition = editions.get(reqEdition);
|
||||
if (edition != null) {
|
||||
reqEdition = edition.getCode();
|
||||
reqEdition = edition.getCode();
|
||||
}
|
||||
}
|
||||
|
||||
if (request.artIndex <= 0) { // this stands for 'random art'
|
||||
List<PaperCard> candidates = new ArrayList<PaperCard>(9); // 9 cards with same name per set is a maximum of what has been printed (Arnchenemy)
|
||||
for (PaperCard pc : cards) {
|
||||
if (pc.getEdition().equalsIgnoreCase(reqEdition) || reqEdition == null) {
|
||||
candidates.add(pc);
|
||||
Collection<PaperCard> candidates;
|
||||
if (reqEdition == null) {
|
||||
candidates = cards;
|
||||
}
|
||||
else {
|
||||
candidates = new ArrayList<PaperCard>();
|
||||
for (PaperCard pc : cards) {
|
||||
if (pc.getEdition().equalsIgnoreCase(reqEdition)) {
|
||||
candidates.add(pc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (candidates.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CardPool extends ItemPool<PaperCard> {
|
||||
public void add(String cardName, String setCode, final int artIndex, final int amount) {
|
||||
PaperCard cp = StaticData.instance().getCommonCards().getCard(cardName, setCode, artIndex);
|
||||
boolean isCommonCard = cp != null;
|
||||
if ( !isCommonCard ) {
|
||||
if (!isCommonCard) {
|
||||
cp = StaticData.instance().getVariantCards().getCard(cardName, setCode);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ public class Aggregates {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static final <K, U> Iterable<U> uniqueByLast(final Iterable<U> source, final Function<U, K> fnUniqueKey) { // this might be exotic
|
||||
final Map<K, U> uniques = new Hashtable<K, U>();
|
||||
for (final U c : source) {
|
||||
|
||||
Reference in New Issue
Block a user