Fix so FatPacks load

Fix references to non-existant quest icon files
This commit is contained in:
drdev
2014-04-10 02:43:51 +00:00
parent 53c090def2
commit 221be3d93d
4 changed files with 109 additions and 85 deletions

View File

@@ -56,7 +56,7 @@ public class StaticData {
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.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")));
}

View File

@@ -79,8 +79,9 @@ public final class CardDb implements ICardDatabase {
public static CardRequest fromString(String name) {
boolean isFoil = name.endsWith(foilSuffix);
if( isFoil )
if (isFoil) {
name = name.substring(0, name.length() - foilSuffix.length());
}
String[] nameParts = TextUtil.split(name, NameSetSeparator);
@@ -95,8 +96,9 @@ public final class CardDb implements ICardDatabase {
int artIndex = artPos > 0 ? Integer.parseInt(nameParts[artPos]) : 0;
String setName = setPos > 0 ? nameParts[setPos] : null;
if( "???".equals(setName) )
if ("???".equals(setName)) {
setName = null;
}
return new CardRequest(cardName, setName, artIndex, isFoil);
}
@@ -109,8 +111,9 @@ public final class CardDb implements ICardDatabase {
List<String> missingCards = new ArrayList<String>();
for (CardEdition e : editions.getOrderedEditions()) {
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)");
}
String lastCardName = null;
int artIdx = 1;
for (CardEdition.CardInSet cis : e.getCards()) {
@@ -121,21 +124,25 @@ public final class CardDb implements ICardDatabase {
lastCardName = cis.name;
}
CardRules cr = rulesByName.get(lastCardName);
if( cr != null )
if (cr != null) {
addCard(new PaperCard(cr, e.getCode(), cis.rarity, artIdx));
else
}
else {
missingCards.add(cis.name);
}
}
if (isCoreExpSet && logMissingPerEdition) {
if(missingCards.isEmpty())
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 )
if (isCoreExpSet && logMissingSummary) {
allMissingCards.addAll(missingCards);
}
missingCards.clear();
}
@@ -144,8 +151,7 @@ public final class CardDb implements ICardDatabase {
}
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. ");
addCard(new PaperCard(cr, CardEdition.UNKNOWN.getCode(), CardRarity.Special, 1));
}
@@ -176,24 +182,27 @@ public final class CardDb implements ICardDatabase {
@Override
public PaperCard getCard(final String cardName, String setName) {
CardRequest request = CardRequest.fromString(cardName);
if(setName != null)
if (setName != null) {
request.edition = setName;
}
return tryGetCard(request);
}
@Override
public PaperCard getCard(final String cardName, String setName, int artIndex) {
CardRequest request = CardRequest.fromString(cardName);
if(setName != null)
if (setName != null) {
request.edition = setName;
if(artIndex > 0)
}
if (artIndex > 0) {
request.artIndex = artIndex;
}
return tryGetCard(request);
}
private PaperCard tryGetCard(CardRequest request) {
Collection<PaperCard> cards = allCardsByName.get(request.cardName);
if ( null == cards ) return null;
if (null == cards) { return null; }
PaperCard result = null;
@@ -211,8 +220,9 @@ public final class CardDb implements ICardDatabase {
candidates.add(pc);
}
if (candidates.isEmpty())
if (candidates.isEmpty()) {
return null;
}
result = Aggregates.random(candidates);
} else {
for (PaperCard pc : cards) {
@@ -222,7 +232,7 @@ public final class CardDb implements ICardDatabase {
}
}
}
if ( result == null ) return null;
if (result == null) { return null; }
return request.isFoil ? getFoiled(result) : result;
}
@@ -267,12 +277,14 @@ public final class CardDb implements ICardDatabase {
for (int i = 0 ; i < sz ; i++) {
PaperCard pc = cards.get(i);
CardEdition ed = editions.get(pc.getEdition());
if(fromSet != null && !fromSet.accept(ed))
if (fromSet != null && !fromSet.accept(ed)) {
continue;
}
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 cards.get(i + MyRandom.getRandom().nextInt(sz-i));
}
}
@@ -360,9 +372,11 @@ public final class CardDb implements ICardDatabase {
@Override
public boolean apply(final PaperCard subject) {
Collection<PaperCard> cc = allCardsByName.get(subject.getName());
for(PaperCard c : cc)
if (sets.contains(c.getEdition()))
for (PaperCard c : cc) {
if (sets.contains(c.getEdition())) {
return true;
}
}
return false;
}
}
@@ -416,16 +430,19 @@ public final class CardDb implements ICardDatabase {
break;
}
}
else
else {
cE = CardEdition.UNKNOWN;
}
}
// 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));
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()));
}
return new PaperCard(CardRules.getUnsupportedCardNamed(request.cardName), cE.getCode(), cR, 1);
@@ -453,8 +470,9 @@ public final class CardDb implements ICardDatabase {
for (CardEdition e : editions.getOrderedEditions()) {
int artIdx = 1;
for (CardInSet cis : e.getCards()) {
if( !cis.name.equals(cardName) )
if (!cis.name.equals(cardName)) {
continue;
}
paperCards.add(new PaperCard(rules, e.getCode(), cis.rarity, artIdx++));
}
}
@@ -467,21 +485,23 @@ public final class CardDb implements ICardDatabase {
lastEdition = tuple.getKey();
}
CardEdition ed = editions.get(lastEdition);
if(null == ed)
if (null == ed) {
continue;
}
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));
}
// 2. add them to db
for (PaperCard paperCard : paperCards)
for (PaperCard paperCard : paperCards) {
addCard(paperCard);
}
// 3. reindex can be temporary disabled and run after the whole batch of rules is added to db.
if(immediateReindex)
if (immediateReindex) {
reIndex();
}
return result;
}
public void removeCard(String name) {
@@ -491,11 +511,14 @@ public final class CardDb implements ICardDatabase {
Iterator<PaperCard> it = allCards.iterator();
while(it.hasNext()) {
PaperCard pc = it.next();
if( pc.getName().equalsIgnoreCase(name))
if (pc.getName().equalsIgnoreCase(name)) {
it.remove();
}
}
public void rebuildIndex() { reIndex(); }
}
public void rebuildIndex() {
reIndex();
}
public boolean isImmediateReindex() {
return immediateReindex;

View File

@@ -1,5 +1,6 @@
package forge.screens.home.quest;
import forge.assets.FSkinProp;
import forge.model.FModel;
import forge.quest.data.QuestPreferences;
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.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");
pnlRewards.add(lblErrRewards, "w 100%!, h 30px!, span 2 1");
@@ -100,7 +101,7 @@ public class QuestPreferencesHandler extends SkinnedPanel {
pnlDifficulty.setOpaque(false);
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");
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.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");
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.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");
constraints1 = "w 60px, h 26px!";

View File

@@ -27,7 +27,7 @@ public class CardDatabaseHelper {
private static void initialize() {
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() {