mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Fix so FatPacks load
Fix references to non-existant quest icon files
This commit is contained in:
@@ -56,7 +56,7 @@ public class StaticData {
|
|||||||
this.boosters = new StorageBase<SealedProduct.Template>("Boosters", editions.getBoosterGenerator());
|
this.boosters = new StorageBase<SealedProduct.Template>("Boosters", editions.getBoosterGenerator());
|
||||||
this.specialBoosters = new StorageBase<SealedProduct.Template>("Special boosters", new SealedProduct.Template.Reader(new File(blockDataFolder, "boosters-special.txt")));
|
this.specialBoosters = new StorageBase<SealedProduct.Template>("Special boosters", new SealedProduct.Template.Reader(new File(blockDataFolder, "boosters-special.txt")));
|
||||||
this.tournaments = new StorageBase<SealedProduct.Template>("Starter sets", new SealedProduct.Template.Reader(new File(blockDataFolder, "starters.txt")));
|
this.tournaments = new StorageBase<SealedProduct.Template>("Starter sets", new SealedProduct.Template.Reader(new File(blockDataFolder, "starters.txt")));
|
||||||
this.fatPacks = new StorageBase<FatPack.Template>("Fat packs", new FatPack.Template.Reader("res/blockdata/fatpacks.txt"));
|
this.fatPacks = new StorageBase<FatPack.Template>("Fat packs", new FatPack.Template.Reader(blockDataFolder + "fatpacks.txt"));
|
||||||
this.printSheets = new StorageBase<PrintSheet>("Special print runs", new PrintSheet.Reader(new File(blockDataFolder, "printsheets.txt")));
|
this.printSheets = new StorageBase<PrintSheet>("Special print runs", new PrintSheet.Reader(new File(blockDataFolder, "printsheets.txt")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,8 +79,9 @@ public final class CardDb implements ICardDatabase {
|
|||||||
|
|
||||||
public static CardRequest fromString(String name) {
|
public static CardRequest fromString(String name) {
|
||||||
boolean isFoil = name.endsWith(foilSuffix);
|
boolean isFoil = name.endsWith(foilSuffix);
|
||||||
if( isFoil )
|
if (isFoil) {
|
||||||
name = name.substring(0, name.length() - foilSuffix.length());
|
name = name.substring(0, name.length() - foilSuffix.length());
|
||||||
|
}
|
||||||
|
|
||||||
String[] nameParts = TextUtil.split(name, NameSetSeparator);
|
String[] nameParts = TextUtil.split(name, NameSetSeparator);
|
||||||
|
|
||||||
@@ -88,15 +89,16 @@ public final class CardDb implements ICardDatabase {
|
|||||||
int artPos = nameParts.length >= 2 && StringUtils.isNumeric(nameParts[1]) ? 1 : nameParts.length >= 3 && StringUtils.isNumeric(nameParts[2]) ? 2 : -1;
|
int artPos = nameParts.length >= 2 && StringUtils.isNumeric(nameParts[1]) ? 1 : nameParts.length >= 3 && StringUtils.isNumeric(nameParts[2]) ? 2 : -1;
|
||||||
|
|
||||||
String cardName = nameParts[0];
|
String cardName = nameParts[0];
|
||||||
if( cardName.endsWith(foilSuffix)) {
|
if (cardName.endsWith(foilSuffix)) {
|
||||||
cardName = cardName.substring(0, cardName.length() - foilSuffix.length());
|
cardName = cardName.substring(0, cardName.length() - foilSuffix.length());
|
||||||
isFoil = true;
|
isFoil = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int artIndex = artPos > 0 ? Integer.parseInt(nameParts[artPos]) : 0;
|
int artIndex = artPos > 0 ? Integer.parseInt(nameParts[artPos]) : 0;
|
||||||
String setName = setPos > 0 ? nameParts[setPos] : null;
|
String setName = setPos > 0 ? nameParts[setPos] : null;
|
||||||
if( "???".equals(setName) )
|
if ("???".equals(setName)) {
|
||||||
setName = null;
|
setName = null;
|
||||||
|
}
|
||||||
|
|
||||||
return new CardRequest(cardName, setName, artIndex, isFoil);
|
return new CardRequest(cardName, setName, artIndex, isFoil);
|
||||||
}
|
}
|
||||||
@@ -107,45 +109,49 @@ public final class CardDb implements ICardDatabase {
|
|||||||
this.editions = editions0;
|
this.editions = editions0;
|
||||||
Set<String> allMissingCards = new LinkedHashSet<String>();
|
Set<String> allMissingCards = new LinkedHashSet<String>();
|
||||||
List<String> missingCards = new ArrayList<String>();
|
List<String> missingCards = new ArrayList<String>();
|
||||||
for(CardEdition e : editions.getOrderedEditions()) {
|
for (CardEdition e : editions.getOrderedEditions()) {
|
||||||
boolean isCoreExpSet = e.getType() == CardEdition.Type.CORE || e.getType() == CardEdition.Type.EXPANSION || e.getType() == CardEdition.Type.REPRINT;
|
boolean isCoreExpSet = e.getType() == CardEdition.Type.CORE || e.getType() == CardEdition.Type.EXPANSION || e.getType() == CardEdition.Type.REPRINT;
|
||||||
if(logMissingPerEdition && isCoreExpSet)
|
if (logMissingPerEdition && isCoreExpSet) {
|
||||||
System.out.print(e.getName() + " (" + e.getCards().length + " cards)");
|
System.out.print(e.getName() + " (" + e.getCards().length + " cards)");
|
||||||
|
}
|
||||||
String lastCardName = null;
|
String lastCardName = null;
|
||||||
int artIdx = 1;
|
int artIdx = 1;
|
||||||
for(CardEdition.CardInSet cis : e.getCards()) {
|
for (CardEdition.CardInSet cis : e.getCards()) {
|
||||||
if ( cis.name.equals(lastCardName) )
|
if (cis.name.equals(lastCardName))
|
||||||
artIdx++;
|
artIdx++;
|
||||||
else {
|
else {
|
||||||
artIdx = 1;
|
artIdx = 1;
|
||||||
lastCardName = cis.name;
|
lastCardName = cis.name;
|
||||||
}
|
}
|
||||||
CardRules cr = rulesByName.get(lastCardName);
|
CardRules cr = rulesByName.get(lastCardName);
|
||||||
if( cr != null )
|
if (cr != null) {
|
||||||
addCard(new PaperCard(cr, e.getCode(), cis.rarity, artIdx));
|
addCard(new PaperCard(cr, e.getCode(), cis.rarity, artIdx));
|
||||||
else
|
}
|
||||||
missingCards.add(cis.name);
|
|
||||||
}
|
|
||||||
if(isCoreExpSet && logMissingPerEdition) {
|
|
||||||
if(missingCards.isEmpty())
|
|
||||||
System.out.println(" ... 100% ");
|
|
||||||
else {
|
else {
|
||||||
int missing = (e.getCards().length - missingCards.size()) * 10000 / e.getCards().length;
|
missingCards.add(cis.name);
|
||||||
System.out.printf(" ... %.2f%% (%s missing: %s )%n", missing * 0.01f, Lang.nounWithAmount(missingCards.size(), "card"), StringUtils.join(missingCards, " | ") );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( isCoreExpSet && logMissingSummary )
|
if (isCoreExpSet && logMissingPerEdition) {
|
||||||
|
if (missingCards.isEmpty()) {
|
||||||
|
System.out.println(" ... 100% ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int missing = (e.getCards().length - missingCards.size()) * 10000 / e.getCards().length;
|
||||||
|
System.out.printf(" ... %.2f%% (%s missing: %s)%n", missing * 0.01f, Lang.nounWithAmount(missingCards.size(), "card"), StringUtils.join(missingCards, " | "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isCoreExpSet && logMissingSummary) {
|
||||||
allMissingCards.addAll(missingCards);
|
allMissingCards.addAll(missingCards);
|
||||||
|
}
|
||||||
missingCards.clear();
|
missingCards.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( logMissingSummary ) {
|
if (logMissingSummary) {
|
||||||
System.out.printf("Totally %d cards not implemented: %s\n", allMissingCards.size(), StringUtils.join(allMissingCards, " | "));
|
System.out.printf("Totally %d cards not implemented: %s\n", allMissingCards.size(), StringUtils.join(allMissingCards, " | "));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(CardRules cr : rulesByName.values()) {
|
for (CardRules cr : rulesByName.values()) {
|
||||||
if( !allCardsByName.containsKey(cr.getName()) )
|
if (!allCardsByName.containsKey(cr.getName())) {
|
||||||
{
|
|
||||||
System.err.println("The card " + cr.getName() + " was not assigned to any set. Adding it to UNKNOWN set... to fix see res/cardeditions/ folder. ");
|
System.err.println("The card " + cr.getName() + " was not assigned to any set. Adding it to UNKNOWN set... to fix see res/cardeditions/ folder. ");
|
||||||
addCard(new PaperCard(cr, CardEdition.UNKNOWN.getCode(), CardRarity.Special, 1));
|
addCard(new PaperCard(cr, CardEdition.UNKNOWN.getCode(), CardRarity.Special, 1));
|
||||||
}
|
}
|
||||||
@@ -161,7 +167,7 @@ public final class CardDb implements ICardDatabase {
|
|||||||
private void reIndex() {
|
private void reIndex() {
|
||||||
uniqueCardsByName.clear();
|
uniqueCardsByName.clear();
|
||||||
allCards.clear();
|
allCards.clear();
|
||||||
for(Entry<String, Collection<PaperCard>> kv : allCardsByName.asMap().entrySet()) {
|
for (Entry<String, Collection<PaperCard>> kv : allCardsByName.asMap().entrySet()) {
|
||||||
uniqueCardsByName.put(kv.getKey(), Iterables.getFirst(kv.getValue(), null));
|
uniqueCardsByName.put(kv.getKey(), Iterables.getFirst(kv.getValue(), null));
|
||||||
allCards.addAll(kv.getValue());
|
allCards.addAll(kv.getValue());
|
||||||
}
|
}
|
||||||
@@ -176,53 +182,57 @@ public final class CardDb implements ICardDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public PaperCard getCard(final String cardName, String setName) {
|
public PaperCard getCard(final String cardName, String setName) {
|
||||||
CardRequest request = CardRequest.fromString(cardName);
|
CardRequest request = CardRequest.fromString(cardName);
|
||||||
if(setName != null)
|
if (setName != null) {
|
||||||
request.edition = setName;
|
request.edition = setName;
|
||||||
|
}
|
||||||
return tryGetCard(request);
|
return tryGetCard(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaperCard getCard(final String cardName, String setName, int artIndex) {
|
public PaperCard getCard(final String cardName, String setName, int artIndex) {
|
||||||
CardRequest request = CardRequest.fromString(cardName);
|
CardRequest request = CardRequest.fromString(cardName);
|
||||||
if(setName != null)
|
if (setName != null) {
|
||||||
request.edition = setName;
|
request.edition = setName;
|
||||||
if(artIndex > 0)
|
}
|
||||||
|
if (artIndex > 0) {
|
||||||
request.artIndex = artIndex;
|
request.artIndex = artIndex;
|
||||||
|
}
|
||||||
return tryGetCard(request);
|
return tryGetCard(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PaperCard tryGetCard(CardRequest request) {
|
private PaperCard tryGetCard(CardRequest request) {
|
||||||
Collection<PaperCard> cards = allCardsByName.get(request.cardName);
|
Collection<PaperCard> cards = allCardsByName.get(request.cardName);
|
||||||
if ( null == cards ) return null;
|
if (null == cards) { return null; }
|
||||||
|
|
||||||
PaperCard result = null;
|
PaperCard result = null;
|
||||||
|
|
||||||
String reqEdition = request.edition;
|
String reqEdition = request.edition;
|
||||||
if(reqEdition != null && !editions.contains(reqEdition)) {
|
if (reqEdition != null && !editions.contains(reqEdition)) {
|
||||||
CardEdition edition = editions.get(reqEdition);
|
CardEdition edition = editions.get(reqEdition);
|
||||||
if( edition != null )
|
if (edition != null)
|
||||||
reqEdition = edition.getCode();
|
reqEdition = edition.getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( request.artIndex <= 0 ) { // this stands for 'random art'
|
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)
|
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 ) {
|
for (PaperCard pc : cards) {
|
||||||
if( pc.getEdition().equalsIgnoreCase(reqEdition) || reqEdition == null )
|
if (pc.getEdition().equalsIgnoreCase(reqEdition) || reqEdition == null)
|
||||||
candidates.add(pc);
|
candidates.add(pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (candidates.isEmpty())
|
if (candidates.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
result = Aggregates.random(candidates);
|
result = Aggregates.random(candidates);
|
||||||
} else {
|
} else {
|
||||||
for( PaperCard pc : cards ) {
|
for (PaperCard pc : cards) {
|
||||||
if( pc.getEdition().equalsIgnoreCase(reqEdition) && request.artIndex == pc.getArtIndex() ) {
|
if (pc.getEdition().equalsIgnoreCase(reqEdition) && request.artIndex == pc.getArtIndex()) {
|
||||||
result = pc;
|
result = pc;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( result == null ) return null;
|
if (result == null) { return null; }
|
||||||
|
|
||||||
return request.isFoil ? getFoiled(result) : result;
|
return request.isFoil ? getFoiled(result) : result;
|
||||||
}
|
}
|
||||||
@@ -242,37 +252,39 @@ public final class CardDb implements ICardDatabase {
|
|||||||
final CardRequest cr = CardRequest.fromString(cardName);
|
final CardRequest cr = CardRequest.fromString(cardName);
|
||||||
List<PaperCard> cards = this.allCardsByName.get(cr.cardName);
|
List<PaperCard> cards = this.allCardsByName.get(cr.cardName);
|
||||||
|
|
||||||
if ( StringUtils.isNotBlank(cr.edition) ) {
|
if (StringUtils.isNotBlank(cr.edition)) {
|
||||||
cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() {
|
cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() {
|
||||||
@Override public boolean apply(PaperCard input) { return input.getEdition().equalsIgnoreCase(cr.edition); }
|
@Override public boolean apply(PaperCard input) { return input.getEdition().equalsIgnoreCase(cr.edition); }
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if(artIndex == -1 && cr.artIndex > 0) {
|
if (artIndex == -1 && cr.artIndex > 0) {
|
||||||
artIndex = cr.artIndex;
|
artIndex = cr.artIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sz = cards.size();
|
int sz = cards.size();
|
||||||
if( fromSet == SetPreference.Earliest || fromSet == SetPreference.EarliestCoreExp) {
|
if (fromSet == SetPreference.Earliest || fromSet == SetPreference.EarliestCoreExp) {
|
||||||
for(int i = sz - 1 ; i >= 0 ; i--) {
|
for (int i = sz - 1 ; i >= 0 ; i--) {
|
||||||
PaperCard pc = cards.get(i);
|
PaperCard pc = cards.get(i);
|
||||||
CardEdition ed = editions.get(pc.getEdition());
|
CardEdition ed = editions.get(pc.getEdition());
|
||||||
if(!fromSet.accept(ed))
|
if (!fromSet.accept(ed))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if((artIndex <= 0 || pc.getArtIndex() == artIndex) && (printedBefore == null || ed.getDate().before(printedBefore)))
|
if ((artIndex <= 0 || pc.getArtIndex() == artIndex) && (printedBefore == null || ed.getDate().before(printedBefore)))
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} else if( fromSet == SetPreference.LatestCoreExp || fromSet == SetPreference.Latest || fromSet == null || fromSet == SetPreference.Random ) {
|
} else if (fromSet == SetPreference.LatestCoreExp || fromSet == SetPreference.Latest || fromSet == null || fromSet == SetPreference.Random) {
|
||||||
for(int i = 0 ; i < sz ; i++) {
|
for (int i = 0 ; i < sz ; i++) {
|
||||||
PaperCard pc = cards.get(i);
|
PaperCard pc = cards.get(i);
|
||||||
CardEdition ed = editions.get(pc.getEdition());
|
CardEdition ed = editions.get(pc.getEdition());
|
||||||
if(fromSet != null && !fromSet.accept(ed))
|
if (fromSet != null && !fromSet.accept(ed)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if((artIndex < 0 || pc.getArtIndex() == artIndex) && (printedBefore == null || ed.getDate().before(printedBefore))) {
|
if ((artIndex < 0 || pc.getArtIndex() == artIndex) && (printedBefore == null || ed.getDate().before(printedBefore))) {
|
||||||
if( fromSet == SetPreference.LatestCoreExp || fromSet == SetPreference.Latest )
|
if (fromSet == SetPreference.LatestCoreExp || fromSet == SetPreference.Latest) {
|
||||||
return pc;
|
return pc;
|
||||||
|
}
|
||||||
return cards.get(i + MyRandom.getRandom().nextInt(sz-i));
|
return cards.get(i + MyRandom.getRandom().nextInt(sz-i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,8 +301,8 @@ public final class CardDb implements ICardDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public int getPrintCount(String cardName, String edition) {
|
public int getPrintCount(String cardName, String edition) {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
for( PaperCard pc : allCardsByName.get(cardName) ) {
|
for (PaperCard pc : allCardsByName.get(cardName)) {
|
||||||
if( pc.getEdition().equals(edition) )
|
if (pc.getEdition().equals(edition))
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
return cnt;
|
return cnt;
|
||||||
@@ -299,8 +311,8 @@ public final class CardDb implements ICardDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public int getMaxPrintCount(String cardName) {
|
public int getMaxPrintCount(String cardName) {
|
||||||
int max = -1;
|
int max = -1;
|
||||||
for( PaperCard pc : allCardsByName.get(cardName) ) {
|
for (PaperCard pc : allCardsByName.get(cardName)) {
|
||||||
if ( max < pc.getArtIndex() )
|
if (max < pc.getArtIndex())
|
||||||
max = pc.getArtIndex();
|
max = pc.getArtIndex();
|
||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
@@ -311,12 +323,12 @@ public final class CardDb implements ICardDatabase {
|
|||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
Collection<PaperCard> cards = allCardsByName.get(cardName);
|
Collection<PaperCard> cards = allCardsByName.get(cardName);
|
||||||
if ( null == cards ) {
|
if (null == cards) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( PaperCard pc : cards ) {
|
for (PaperCard pc : cards) {
|
||||||
if ( pc.getEdition().equalsIgnoreCase(setName) ) {
|
if (pc.getEdition().equalsIgnoreCase(setName)) {
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,9 +372,11 @@ public final class CardDb implements ICardDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(final PaperCard subject) {
|
public boolean apply(final PaperCard subject) {
|
||||||
Collection<PaperCard> cc = allCardsByName.get(subject.getName());
|
Collection<PaperCard> cc = allCardsByName.get(subject.getName());
|
||||||
for(PaperCard c : cc)
|
for (PaperCard c : cc) {
|
||||||
if (sets.contains(c.getEdition()))
|
if (sets.contains(c.getEdition())) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,7 +384,7 @@ public final class CardDb implements ICardDatabase {
|
|||||||
public StringBuilder appendCardToStringBuilder(PaperCard card, StringBuilder sb) {
|
public StringBuilder appendCardToStringBuilder(PaperCard card, StringBuilder sb) {
|
||||||
final boolean hasBadSetInfo = "???".equals(card.getEdition()) || StringUtils.isBlank(card.getEdition());
|
final boolean hasBadSetInfo = "???".equals(card.getEdition()) || StringUtils.isBlank(card.getEdition());
|
||||||
sb.append(card.getName());
|
sb.append(card.getName());
|
||||||
if(card.isFoil()) {
|
if (card.isFoil()) {
|
||||||
sb.append(CardDb.foilSuffix);
|
sb.append(CardDb.foilSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,10 +409,10 @@ public final class CardDb implements ICardDatabase {
|
|||||||
CardRarity cR = CardRarity.Unknown;
|
CardRarity cR = CardRarity.Unknown;
|
||||||
|
|
||||||
// May iterate over editions and find out if there is any card named 'cardName' but not implemented with Forge script.
|
// May iterate over editions and find out if there is any card named 'cardName' but not implemented with Forge script.
|
||||||
if( StringUtils.isBlank(request.edition) ) {
|
if (StringUtils.isBlank(request.edition)) {
|
||||||
for(CardEdition e : editions) {
|
for (CardEdition e : editions) {
|
||||||
for(CardInSet cs : e.getCards() ) {
|
for (CardInSet cs : e.getCards()) {
|
||||||
if( cs.name.equals(request.cardName)) {
|
if (cs.name.equals(request.cardName)) {
|
||||||
cE = e;
|
cE = e;
|
||||||
cR = cs.rarity;
|
cR = cs.rarity;
|
||||||
break;
|
break;
|
||||||
@@ -409,23 +423,26 @@ public final class CardDb implements ICardDatabase {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cE = editions.get(request.edition);
|
cE = editions.get(request.edition);
|
||||||
if ( cE != null )
|
if (cE != null)
|
||||||
for(CardInSet cs : cE.getCards() ) {
|
for (CardInSet cs : cE.getCards()) {
|
||||||
if( cs.name.equals(request.cardName)) {
|
if (cs.name.equals(request.cardName)) {
|
||||||
cR = cs.rarity;
|
cR = cs.rarity;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
cE = CardEdition.UNKNOWN;
|
cE = CardEdition.UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Write to log that attempt,
|
// Write to log that attempt,
|
||||||
if (cR == CardRarity.Unknown )
|
if (cR == CardRarity.Unknown) {
|
||||||
System.err.println(String.format("An unknown card found when loading Forge decks: \"%s\" Forge does not know of such a card's existence. Have you mistyped the card name?", cardName));
|
System.err.println(String.format("An unknown card found when loading Forge decks: \"%s\" Forge does not know of such a card's existence. Have you mistyped the card name?", cardName));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
System.err.println(String.format("An unsupported card was requested: \"%s\" from \"%s\" set. We're sorry, but you cannot use this card yet.", request.cardName, cE.getName()));
|
System.err.println(String.format("An unsupported card was requested: \"%s\" from \"%s\" set. We're sorry, but you cannot use this card yet.", request.cardName, cE.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
return new PaperCard(CardRules.getUnsupportedCardNamed(request.cardName), cE.getCode(), cR, 1);
|
return new PaperCard(CardRules.getUnsupportedCardNamed(request.cardName), cE.getCode(), cR, 1);
|
||||||
|
|
||||||
@@ -450,38 +467,41 @@ public final class CardDb implements ICardDatabase {
|
|||||||
// 1. generate all paper cards from edition data we have (either explicit, or found in res/editions, or add to unknown edition)
|
// 1. generate all paper cards from edition data we have (either explicit, or found in res/editions, or add to unknown edition)
|
||||||
List<PaperCard> paperCards = new ArrayList<PaperCard>();
|
List<PaperCard> paperCards = new ArrayList<PaperCard>();
|
||||||
if (null == whenItWasPrinted || whenItWasPrinted.isEmpty()) {
|
if (null == whenItWasPrinted || whenItWasPrinted.isEmpty()) {
|
||||||
for(CardEdition e : editions.getOrderedEditions()) {
|
for (CardEdition e : editions.getOrderedEditions()) {
|
||||||
int artIdx = 1;
|
int artIdx = 1;
|
||||||
for(CardInSet cis : e.getCards()) {
|
for (CardInSet cis : e.getCards()) {
|
||||||
if( !cis.name.equals(cardName) )
|
if (!cis.name.equals(cardName)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
paperCards.add(new PaperCard(rules, e.getCode(), cis.rarity, artIdx++));
|
paperCards.add(new PaperCard(rules, e.getCode(), cis.rarity, artIdx++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String lastEdition = null;
|
String lastEdition = null;
|
||||||
int artIdx = 0;
|
int artIdx = 0;
|
||||||
for(Pair<String, CardRarity> tuple : whenItWasPrinted){
|
for (Pair<String, CardRarity> tuple : whenItWasPrinted){
|
||||||
if(!tuple.getKey().equals(lastEdition)) {
|
if (!tuple.getKey().equals(lastEdition)) {
|
||||||
artIdx = 1;
|
artIdx = 1;
|
||||||
lastEdition = tuple.getKey();
|
lastEdition = tuple.getKey();
|
||||||
}
|
}
|
||||||
CardEdition ed = editions.get(lastEdition);
|
CardEdition ed = editions.get(lastEdition);
|
||||||
if(null == ed)
|
if (null == ed) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
paperCards.add(new PaperCard(rules, lastEdition, tuple.getValue(), artIdx++));
|
paperCards.add(new PaperCard(rules, lastEdition, tuple.getValue(), artIdx++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(paperCards.isEmpty())
|
if (paperCards.isEmpty()) {
|
||||||
paperCards.add(new PaperCard(rules, CardEdition.UNKNOWN.getCode(), CardRarity.Special, 1));
|
paperCards.add(new PaperCard(rules, CardEdition.UNKNOWN.getCode(), CardRarity.Special, 1));
|
||||||
|
}
|
||||||
// 2. add them to db
|
// 2. add them to db
|
||||||
for (PaperCard paperCard : paperCards)
|
for (PaperCard paperCard : paperCards) {
|
||||||
addCard(paperCard);
|
addCard(paperCard);
|
||||||
|
}
|
||||||
// 3. reindex can be temporary disabled and run after the whole batch of rules is added to db.
|
// 3. reindex can be temporary disabled and run after the whole batch of rules is added to db.
|
||||||
if(immediateReindex)
|
if (immediateReindex) {
|
||||||
reIndex();
|
reIndex();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public void removeCard(String name) {
|
public void removeCard(String name) {
|
||||||
@@ -491,11 +511,14 @@ public final class CardDb implements ICardDatabase {
|
|||||||
Iterator<PaperCard> it = allCards.iterator();
|
Iterator<PaperCard> it = allCards.iterator();
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
PaperCard pc = it.next();
|
PaperCard pc = it.next();
|
||||||
if( pc.getName().equalsIgnoreCase(name))
|
if (pc.getName().equalsIgnoreCase(name)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void rebuildIndex() { reIndex(); }
|
public void rebuildIndex() {
|
||||||
|
reIndex();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isImmediateReindex() {
|
public boolean isImmediateReindex() {
|
||||||
return immediateReindex;
|
return immediateReindex;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package forge.screens.home.quest;
|
package forge.screens.home.quest;
|
||||||
|
|
||||||
|
import forge.assets.FSkinProp;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.quest.data.QuestPreferences;
|
import forge.quest.data.QuestPreferences;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
@@ -59,7 +60,7 @@ public class QuestPreferencesHandler extends SkinnedPanel {
|
|||||||
pnlRewards.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
|
pnlRewards.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
|
||||||
|
|
||||||
pnlRewards.add(new FLabel.Builder().text("Rewards")
|
pnlRewards.add(new FLabel.Builder().text("Rewards")
|
||||||
.icon(new FSkin.UnskinnedIcon("res/images/icons/CoinIcon.png")).build(),
|
.icon(FSkin.getImage(FSkinProp.ICO_QUEST_COIN)).build(),
|
||||||
"w 100%!, h 30px!, span 2 1");
|
"w 100%!, h 30px!, span 2 1");
|
||||||
pnlRewards.add(lblErrRewards, "w 100%!, h 30px!, span 2 1");
|
pnlRewards.add(lblErrRewards, "w 100%!, h 30px!, span 2 1");
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@ public class QuestPreferencesHandler extends SkinnedPanel {
|
|||||||
pnlDifficulty.setOpaque(false);
|
pnlDifficulty.setOpaque(false);
|
||||||
pnlDifficulty.setLayout(new MigLayout("insets 0, gap 0, wrap 5"));
|
pnlDifficulty.setLayout(new MigLayout("insets 0, gap 0, wrap 5"));
|
||||||
|
|
||||||
pnlDifficulty.add(new FLabel.Builder().text("Difficulty Adjustments").icon(new FSkin.UnskinnedIcon("res/images/icons/NotesIcon.png")).build(), "w 100%!, h 30px!, span 5 1");
|
pnlDifficulty.add(new FLabel.Builder().text("Difficulty Adjustments").icon(FSkin.getImage(FSkinProp.ICO_QUEST_NOTES)).build(), "w 100%!, h 30px!, span 5 1");
|
||||||
pnlDifficulty.add(lblErrDifficulty, "w 100%!, h 30px!, span 5 1");
|
pnlDifficulty.add(lblErrDifficulty, "w 100%!, h 30px!, span 5 1");
|
||||||
|
|
||||||
constraints1 = "w 60px!, h 26px!";
|
constraints1 = "w 60px!, h 26px!";
|
||||||
@@ -183,7 +184,7 @@ public class QuestPreferencesHandler extends SkinnedPanel {
|
|||||||
pnlBooster.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
|
pnlBooster.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
|
||||||
|
|
||||||
pnlBooster.add(new FLabel.Builder().text("Booster Pack Ratios")
|
pnlBooster.add(new FLabel.Builder().text("Booster Pack Ratios")
|
||||||
.icon(new FSkin.UnskinnedIcon("res/images/icons/BookIcon.png")).build(),
|
.icon(FSkin.getImage(FSkinProp.ICO_QUEST_BOOK)).build(),
|
||||||
"w 100%!, h 30px!, span 2 1");
|
"w 100%!, h 30px!, span 2 1");
|
||||||
pnlBooster.add(lblErrBooster, "w 100%!, h 30px!, span 2 1");
|
pnlBooster.add(lblErrBooster, "w 100%!, h 30px!, span 2 1");
|
||||||
|
|
||||||
@@ -203,7 +204,7 @@ public class QuestPreferencesHandler extends SkinnedPanel {
|
|||||||
pnlShop.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
|
pnlShop.setLayout(new MigLayout("insets 0, gap 0, wrap 2"));
|
||||||
|
|
||||||
pnlShop.add(new FLabel.Builder().text("Shop Preferences")
|
pnlShop.add(new FLabel.Builder().text("Shop Preferences")
|
||||||
.icon(new FSkin.UnskinnedIcon("res/images/icons/CoinIcon.png")).build(), "w 100%!, h 30px!, span 2 1");
|
.icon(FSkin.getImage(FSkinProp.ICO_QUEST_COIN)).build(), "w 100%!, h 30px!, span 2 1");
|
||||||
pnlShop.add(lblErrShop, "w 100%!, h 30px!, span 2 1");
|
pnlShop.add(lblErrShop, "w 100%!, h 30px!, span 2 1");
|
||||||
|
|
||||||
constraints1 = "w 60px, h 26px!";
|
constraints1 = "w 60px, h 26px!";
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class CardDatabaseHelper {
|
|||||||
|
|
||||||
private static void initialize() {
|
private static void initialize() {
|
||||||
final CardStorageReader reader = new CardStorageReader(ForgeConstants.CARD_DATA_DIR, null, null);
|
final CardStorageReader reader = new CardStorageReader(ForgeConstants.CARD_DATA_DIR, null, null);
|
||||||
staticData = new StaticData(reader, "res/editions", "res/blockdata");
|
staticData = new StaticData(reader, ForgeConstants.EDITIONS_DIR, ForgeConstants.BLOCK_DATA_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean hasBeenInitialized() {
|
private static boolean hasBeenInitialized() {
|
||||||
|
|||||||
Reference in New Issue
Block a user