Whitespace cleanup

This commit is contained in:
drdev
2013-11-22 02:23:53 +00:00
parent f934764290
commit 72d0cfdbbc
5 changed files with 175 additions and 205 deletions

View File

@@ -21,90 +21,83 @@ import forge.util.storage.StorageBase;
* @author Max * @author Max
*/ */
public class StaticData { public class StaticData {
private final CardDb commonCards;
private final CardDb variantCards;
private final CardEdition.Collection editions;
private final IStorage<SealedProduct.Template> boosters;
private final IStorage<SealedProduct.Template> specialBoosters;
private final IStorage<SealedProduct.Template> tournaments;
private final IStorage<FatPack.Template> fatPacks;
private final IStorage<PrintSheet> printSheets;
private final CardDb commonCards; private static StaticData lastInstance = null;
private final CardDb variantCards;
private final CardEdition.Collection editions;
private final IStorage<SealedProduct.Template> boosters;
private final IStorage<SealedProduct.Template> specialBoosters;
private final IStorage<SealedProduct.Template> tournaments;
private final IStorage<FatPack.Template> fatPacks;
private final IStorage<PrintSheet> printSheets;
private static StaticData lastInstance = null; public StaticData(ICardStorageReader reader, String editionFolder, String blockDataFolder) {
this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder)));
lastInstance = this;
final Map<String, CardRules> regularCards = new TreeMap<String, CardRules>(String.CASE_INSENSITIVE_ORDER);
final Map<String, CardRules> variantsCards = new TreeMap<String, CardRules>(String.CASE_INSENSITIVE_ORDER);
List<CardRules> rules = reader.loadCards();
for (CardRules card : rules) {
if (null == card) continue;
public StaticData(ICardStorageReader reader, String editionFolder, String blockDataFolder) { final String cardName = card.getName();
this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder))); if ( card.isVariant() ) {
lastInstance = this; variantsCards.put(cardName, card);
}
else {
regularCards.put(cardName, card);
}
}
final Map<String, CardRules> regularCards = new TreeMap<String, CardRules>(String.CASE_INSENSITIVE_ORDER); commonCards = new CardDb(regularCards, editions, false);
final Map<String, CardRules> variantsCards = new TreeMap<String, CardRules>(String.CASE_INSENSITIVE_ORDER); variantCards = new CardDb(variantsCards, editions, false);
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.printSheets = new StorageBase<PrintSheet>("Special print runs", new PrintSheet.Reader(new File(blockDataFolder, "printsheets.txt")));
}
List<CardRules> rules = reader.loadCards(); public final static StaticData instance() {
for (CardRules card : rules) { return lastInstance;
if (null == card) continue; }
final String cardName = card.getName(); public final CardEdition.Collection getEditions() {
if ( card.isVariant() ) return this.editions;
variantsCards.put(cardName, card); }
else
regularCards.put(cardName, card);
}
commonCards = new CardDb(regularCards, editions, false); /** @return {@link forge.util.storage.IStorageView}<{@link forge.item.FatPackTemplate}> */
variantCards = new CardDb(variantsCards, editions, false); public IStorage<FatPack.Template> getFatPacks() {
return fatPacks;
}
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterTemplate}> */
public final IStorage<SealedProduct.Template> getTournamentPacks() {
return tournaments;
}
this.boosters = new StorageBase<SealedProduct.Template>("Boosters", editions.getBoosterGenerator()); /** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterTemplate}> */
this.specialBoosters = new StorageBase<SealedProduct.Template>("Special boosters", new SealedProduct.Template.Reader(new File(blockDataFolder, "boosters-special.txt"))); public final IStorage<SealedProduct.Template> getBoosters() {
this.tournaments = new StorageBase<SealedProduct.Template>("Starter sets", new SealedProduct.Template.Reader(new File(blockDataFolder, "starters.txt"))); return boosters;
this.fatPacks = new StorageBase<FatPack.Template>("Fat packs", new FatPack.Template.Reader("res/blockdata/fatpacks.txt")); }
this.printSheets = new StorageBase<PrintSheet>("Special print runs", new PrintSheet.Reader(new File(blockDataFolder, "printsheets.txt")));
}
public final static StaticData instance() { public final IStorage<SealedProduct.Template> getSpecialBoosters() {
return lastInstance; return specialBoosters;
} }
public IStorage<PrintSheet> getPrintSheets() {
return printSheets;
}
public final CardEdition.Collection getEditions() { public CardDb getCommonCards() {
return this.editions; return commonCards;
} }
/** @return {@link forge.util.storage.IStorageView}<{@link forge.item.FatPackTemplate}> */
public IStorage<FatPack.Template> getFatPacks() {
return fatPacks;
}
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterTemplate}> */
public final IStorage<SealedProduct.Template> getTournamentPacks() {
return tournaments;
}
/** @return {@link forge.util.storage.IStorageView}<{@link forge.card.BoosterTemplate}> */
public final IStorage<SealedProduct.Template> getBoosters() {
return boosters;
}
public final IStorage<SealedProduct.Template> getSpecialBoosters() {
return specialBoosters;
}
public IStorage<PrintSheet> getPrintSheets() {
return printSheets;
}
public CardDb getCommonCards() {
return commonCards;
}
public CardDb getVariantCards() {
return variantCards;
}
public CardDb getVariantCards() {
return variantCards;
}
} }

View File

@@ -39,7 +39,6 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;
import forge.card.CardEdition.CardInSet; import forge.card.CardEdition.CardInSet;
import forge.deck.CardPool;
import forge.item.PaperCard; import forge.item.PaperCard;
import forge.util.Aggregates; import forge.util.Aggregates;
import forge.util.CollectionSuppliers; import forge.util.CollectionSuppliers;
@@ -60,7 +59,6 @@ public final class CardDb implements ICardDatabase {
private final Collection<PaperCard> roUniqueCards = Collections.unmodifiableCollection(uniqueCardsByName.values()); private final Collection<PaperCard> roUniqueCards = Collections.unmodifiableCollection(uniqueCardsByName.values());
private final CardEdition.Collection editions; private final CardEdition.Collection editions;
public CardDb(Map<String, CardRules> rules, CardEdition.Collection editions0, boolean logMissingCards) { public CardDb(Map<String, CardRules> rules, CardEdition.Collection editions0, boolean logMissingCards) {
this.rulesByName = rules; this.rulesByName = rules;
this.editions = editions0; this.editions = editions0;
@@ -197,7 +195,6 @@ public final class CardDb implements ICardDatabase {
return null != res && isFoil ? getFoiled(res) : res; return null != res && isFoil ? getFoiled(res) : res;
} }
@Override @Override
public PaperCard tryGetCard(final String cardName, String setName) { public PaperCard tryGetCard(final String cardName, String setName) {
return tryGetCard(cardName, setName, -1); return tryGetCard(cardName, setName, -1);
@@ -280,7 +277,6 @@ public final class CardDb implements ICardDatabase {
return result; return result;
} }
@Override @Override
public PaperCard getCardPrintedByDate(final String name0, final boolean fromLatestSet, Date printedBefore ) { public PaperCard getCardPrintedByDate(final String name0, final boolean fromLatestSet, Date printedBefore ) {
// Sometimes they read from decks things like "CardName|Set" - but we // Sometimes they read from decks things like "CardName|Set" - but we
@@ -300,7 +296,6 @@ public final class CardDb implements ICardDatabase {
@Override @Override
public PaperCard getCard(final String name, final String set, final int artIndex) { public PaperCard getCard(final String name, final String set, final int artIndex) {
final PaperCard result = tryGetCard(name, set, artIndex); final PaperCard result = tryGetCard(name, set, artIndex);
if (null == result) { if (null == result) {
final String message = String.format("Asked for '%s' from '%s' #%d: db didn't find that copy.", name, set, artIndex); final String message = String.format("Asked for '%s' from '%s' #%d: db didn't find that copy.", name, set, artIndex);
@@ -412,5 +407,4 @@ public final class CardDb implements ICardDatabase {
this.immediateReindex = immediateReindex; this.immediateReindex = immediateReindex;
} }
} }
} }

View File

@@ -223,7 +223,6 @@ public final class CardRules implements ICardCharacteristics {
public ColorSet getColorIdentity() { public ColorSet getColorIdentity() {
return colorIdentity; return colorIdentity;
} }
/** Instantiates class, reads a card. For batch operations better create you own reader instance. */ /** Instantiates class, reads a card. For batch operations better create you own reader instance. */
@@ -250,7 +249,6 @@ public final class CardRules implements ICardCharacteristics {
private DeckHints hints = null; private DeckHints hints = null;
private DeckHints needs = null; private DeckHints needs = null;
/** /**
* Reset all fields to parse next card (to avoid allocating new CardRulesReader N times) * Reset all fields to parse next card (to avoid allocating new CardRulesReader N times)
*/ */
@@ -297,7 +295,6 @@ public final class CardRules implements ICardCharacteristics {
return this.getCard(); return this.getCard();
} }
/** /**
* Parses the line. * Parses the line.
* *
@@ -372,7 +369,6 @@ public final class CardRules implements ICardCharacteristics {
case 'O': case 'O':
if ("Oracle".equals(key)) { if ("Oracle".equals(key)) {
this.faces[this.curFace].setOracleText(value); this.faces[this.curFace].setOracleText(value);
} }
break; break;
@@ -423,7 +419,6 @@ public final class CardRules implements ICardCharacteristics {
} }
break; break;
} }
} }
/** /**
@@ -463,7 +458,6 @@ public final class CardRules implements ICardCharacteristics {
*/ */
@Override @Override
public final ManaCostShard next() { public final ManaCostShard next() {
final String unparsed = st.nextToken(); final String unparsed = st.nextToken();
// System.out.println(unparsed); // System.out.println(unparsed);
try { try {

View File

@@ -80,15 +80,11 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
return this.rarity; return this.rarity;
} }
// @Override // @Override
// public String getImageKey() { // public String getImageKey() {
// return getImageLocator(getImageName(), getArtIndex(), true, false); // return getImageLocator(getImageName(), getArtIndex(), true, false);
// } // }
@Override @Override
public String getItemType() { public String getItemType() {
return "Card"; return "Card";
@@ -178,7 +174,6 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
// return String.format("%s|%s", name, cardSet); // return String.format("%s|%s", name, cardSet);
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *

View File

@@ -98,8 +98,6 @@ public class CardStorageReader implements ICardStorageReader {
throw new RuntimeException("CardReader : constructor error -- not a directory -- " + cardsfolder.getAbsolutePath()); throw new RuntimeException("CardReader : constructor error -- not a directory -- " + cardsfolder.getAbsolutePath());
} }
final File zipFile = new File(cardsfolder, "cardsfolder.zip"); final File zipFile = new File(cardsfolder, "cardsfolder.zip");
if (useZip && zipFile.exists()) { if (useZip && zipFile.exists()) {
@@ -115,7 +113,6 @@ public class CardStorageReader implements ICardStorageReader {
} // CardReader() } // CardReader()
private final List<CardRules> loadCardsInRange(final List<File> files, int from, int to) { private final List<CardRules> loadCardsInRange(final List<File> files, int from, int to) {
CardRules.Reader rulesReader = new CardRules.Reader(); CardRules.Reader rulesReader = new CardRules.Reader();
List<CardRules> result = new ArrayList<CardRules>(); List<CardRules> result = new ArrayList<CardRules>();
@@ -127,7 +124,6 @@ public class CardStorageReader implements ICardStorageReader {
} }
private final List<CardRules> loadCardsInRangeFromZip(final List<ZipEntry> files, int from, int to) { private final List<CardRules> loadCardsInRangeFromZip(final List<ZipEntry> files, int from, int to) {
CardRules.Reader rulesReader = new CardRules.Reader(); CardRules.Reader rulesReader = new CardRules.Reader();
List<CardRules> result = new ArrayList<CardRules>(); List<CardRules> result = new ArrayList<CardRules>();
@@ -139,7 +135,6 @@ public class CardStorageReader implements ICardStorageReader {
return result; return result;
} }
/** /**
* Starts reading cards into memory until the given card is found. * Starts reading cards into memory until the given card is found.
* *
@@ -162,7 +157,6 @@ public class CardStorageReader implements ICardStorageReader {
estimatedFilesRemaining = allFiles.size(); estimatedFilesRemaining = allFiles.size();
tasks = makeTaskListForFiles(allFiles); tasks = makeTaskListForFiles(allFiles);
} else { } else {
estimatedFilesRemaining = this.zip.size(); estimatedFilesRemaining = this.zip.size();
ZipEntry entry; ZipEntry entry;
List<ZipEntry> entries = new ArrayList<ZipEntry>(); List<ZipEntry> entries = new ArrayList<ZipEntry>();
@@ -257,7 +251,7 @@ public class CardStorageReader implements ICardStorageReader {
}); });
} }
return tasks; return tasks;
} }
public static List<File> collectCardFiles(List<File> accumulator, File startDir) { public static List<File> collectCardFiles(List<File> accumulator, File startDir) {
String[] list = startDir.list(); String[] list = startDir.list();