mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Updated CardArtPreference Constants value
Also, the CardArtPreference Enum now includes a new methods that allows seamless recognition (and instantiation) of corresponding enum value from Forge Preference - also with backward compatibility.
This commit is contained in:
@@ -53,10 +53,10 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
private List<String> filtered;
|
private List<String> filtered;
|
||||||
|
|
||||||
public enum CardArtPreference {
|
public enum CardArtPreference {
|
||||||
LatestArtAllEditions(false, true),
|
LATEST_ART_ALL_EDITIONS(false, true),
|
||||||
LatestArtExcludedPromoAndOnlineEditions(true, true),
|
LATEST_ART_CORE_EXPANSIONS_REPRINT_ONLY(true, true),
|
||||||
OldArtAllEditions(false, false),
|
ORIGINAL_ART_ALL_EDITIONS(false, false),
|
||||||
OldArtExcludedPromoAndOnlineEditions(true, false);
|
ORIGINAL_ART_CORE_EXPANSIONS_REPRINT_ONLY(true, false);
|
||||||
|
|
||||||
final boolean filterSets;
|
final boolean filterSets;
|
||||||
final boolean latestFirst;
|
final boolean latestFirst;
|
||||||
@@ -72,15 +72,33 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getPreferences(){
|
public static String[] getPreferences(){
|
||||||
return new String[]{"Latest Art (All Editions)",
|
return new String[]{"Latest Card Art (All Editions)",
|
||||||
"Latest Art (Excluded Promo And Online Editions)",
|
"Latest Card Art (Core, Expansions and Reprint Only)",
|
||||||
"Old Art (All Editions)",
|
"Original Card Art (All Editions)",
|
||||||
"Old Art (Excluded Promo And Online Editions)"};
|
"Original Card Art (Core, Expansions and Reprint Only)"};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CardArtPreference fromForgePreference(final String preference){
|
||||||
|
String prefLabel = preference.trim().toLowerCase();
|
||||||
|
if (prefLabel.contains("latest")){
|
||||||
|
if (prefLabel.contains("core"))
|
||||||
|
return LATEST_ART_CORE_EXPANSIONS_REPRINT_ONLY;
|
||||||
|
return LATEST_ART_ALL_EDITIONS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prefLabel.contains("old") || prefLabel.contains("original") || prefLabel.contains("earliest")){
|
||||||
|
if (prefLabel.contains("core"))
|
||||||
|
return ORIGINAL_ART_CORE_EXPANSIONS_REPRINT_ONLY;
|
||||||
|
return ORIGINAL_ART_ALL_EDITIONS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LATEST_ART_ALL_EDITIONS; // DEFAULT fall back
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Placeholder to setup default art Preference - to be moved from Static Data!
|
// Placeholder to setup default art Preference - to be moved from Static Data!
|
||||||
private CardArtPreference defaultCardArtPreference;
|
private CardArtPreference defaultCardArtPreference;
|
||||||
|
private static final CardArtPreference DEFAULT_ART_PREFERENCE = CardArtPreference.LATEST_ART_ALL_EDITIONS;
|
||||||
|
|
||||||
public static class CardRequest {
|
public static class CardRequest {
|
||||||
public String cardName;
|
public String cardName;
|
||||||
@@ -385,17 +403,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
|
|
||||||
public CardArtPreference getCardArtPreference(){ return this.defaultCardArtPreference; }
|
public CardArtPreference getCardArtPreference(){ return this.defaultCardArtPreference; }
|
||||||
public void setCardArtPreference(String artPreference){
|
public void setCardArtPreference(String artPreference){
|
||||||
artPreference = artPreference.replaceAll("[\\s\\(\\)]", "");
|
this.defaultCardArtPreference = CardArtPreference.fromForgePreference(artPreference);
|
||||||
CardArtPreference cardArtPreference = null;
|
|
||||||
try{
|
|
||||||
cardArtPreference = CardArtPreference.valueOf(artPreference);
|
|
||||||
} catch (IllegalArgumentException ex){
|
|
||||||
cardArtPreference = CardArtPreference.LatestArtAllEditions; // default
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
if (cardArtPreference != null)
|
|
||||||
this.defaultCardArtPreference = cardArtPreference;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -797,12 +797,12 @@ public final class CardEdition implements Comparable<CardEdition> {
|
|||||||
public CardEdition getEarliestEditionWithAllCards(CardPool cards) {
|
public CardEdition getEarliestEditionWithAllCards(CardPool cards) {
|
||||||
Set<String> minEditions = new HashSet<>();
|
Set<String> minEditions = new HashSet<>();
|
||||||
|
|
||||||
CardArtPreference strictness = CardArtPreference.OldArtExcludedPromoAndOnlineEditions;
|
CardArtPreference strictness = CardArtPreference.ORIGINAL_ART_CORE_EXPANSIONS_REPRINT_ONLY;
|
||||||
|
|
||||||
for (Entry<PaperCard, Integer> k : cards) {
|
for (Entry<PaperCard, Integer> k : cards) {
|
||||||
PaperCard cp = StaticData.instance().getCommonCards().getCardFromEditions(k.getKey().getName(), strictness);
|
PaperCard cp = StaticData.instance().getCommonCards().getCardFromEditions(k.getKey().getName(), strictness);
|
||||||
if( cp == null && strictness == CardArtPreference.OldArtExcludedPromoAndOnlineEditions) {
|
if( cp == null && strictness == CardArtPreference.ORIGINAL_ART_CORE_EXPANSIONS_REPRINT_ONLY) {
|
||||||
strictness = CardArtPreference.OldArtAllEditions; // card is not found in core and expansions only (probably something CMD or C13)
|
strictness = CardArtPreference.ORIGINAL_ART_ALL_EDITIONS; // card is not found in core and expansions only (probably something CMD or C13)
|
||||||
cp = StaticData.instance().getCommonCards().getCardFromEditions(k.getKey().getName(), strictness);
|
cp = StaticData.instance().getCommonCards().getCardFromEditions(k.getKey().getName(), strictness);
|
||||||
}
|
}
|
||||||
if ( cp == null )
|
if ( cp == null )
|
||||||
|
|||||||
@@ -113,10 +113,10 @@ public class DeckRecognizer {
|
|||||||
useLastSet = null;
|
useLastSet = null;
|
||||||
}
|
}
|
||||||
else if (onlyCoreAndExp) {
|
else if (onlyCoreAndExp) {
|
||||||
useLastSet = CardArtPreference.LatestArtExcludedPromoAndOnlineEditions;
|
useLastSet = CardArtPreference.LATEST_ART_CORE_EXPANSIONS_REPRINT_ONLY;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
useLastSet = CardArtPreference.LatestArtAllEditions;
|
useLastSet = CardArtPreference.LATEST_ART_ALL_EDITIONS;
|
||||||
}
|
}
|
||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6368,7 +6368,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
|||||||
return cp == null ? StaticData.instance().getCommonCards().getCard(name, set) : cp;
|
return cp == null ? StaticData.instance().getCommonCards().getCard(name, set) : cp;
|
||||||
}
|
}
|
||||||
cp = StaticData.instance().getVariantCards().getCard(name);
|
cp = StaticData.instance().getVariantCards().getCard(name);
|
||||||
return cp == null ? StaticData.instance().getCommonCards().getCardFromEditions(name, CardArtPreference.LatestArtAllEditions) : cp;
|
return cp == null ? StaticData.instance().getCommonCards().getCardFromEditions(name, CardArtPreference.LATEST_ART_ALL_EDITIONS) : cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1703,7 +1703,7 @@ public class CardProperty {
|
|||||||
} else if (property.startsWith("set")) {
|
} else if (property.startsWith("set")) {
|
||||||
final String setCode = property.substring(3, 6);
|
final String setCode = property.substring(3, 6);
|
||||||
final PaperCard setCard = StaticData.instance().getCommonCards().getCardFromEditions(card.getName(),
|
final PaperCard setCard = StaticData.instance().getCommonCards().getCardFromEditions(card.getName(),
|
||||||
CardDb.CardArtPreference.OldArtAllEditions);
|
CardDb.CardArtPreference.ORIGINAL_ART_ALL_EDITIONS);
|
||||||
if (!setCard.getEdition().equals(setCode)) {
|
if (!setCard.getEdition().equals(setCode)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user