mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Code cleanup
This commit is contained in:
@@ -87,33 +87,36 @@ 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 EditionCollection editions;
|
private final EditionCollection editions;
|
||||||
|
|
||||||
|
|
||||||
private CardDb(Map<String, CardRules> rules, EditionCollection editions0, boolean logMissingCards) {
|
private CardDb(Map<String, CardRules> rules, EditionCollection editions0, boolean logMissingCards) {
|
||||||
this.rulesByName = rules;
|
this.rulesByName = rules;
|
||||||
this.editions = editions0;
|
this.editions = editions0;
|
||||||
List<String> missingCards = new ArrayList<String>();
|
List<String> missingCards = new ArrayList<String>();
|
||||||
for(CardEdition e : editions.getOrderedEditions()) {
|
for (CardEdition e : editions.getOrderedEditions()) {
|
||||||
boolean worthLogging = logMissingCards && ( e.getType() == Type.CORE || e.getType() == Type.EXPANSION || e.getType() == Type.REPRINT );
|
boolean worthLogging = logMissingCards && ( e.getType() == Type.CORE || e.getType() == Type.EXPANSION || e.getType() == Type.REPRINT );
|
||||||
if(worthLogging)
|
if (worthLogging) {
|
||||||
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 = 0;
|
int artIdx = 0;
|
||||||
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 = 0;
|
artIdx = 0;
|
||||||
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 if (worthLogging)
|
}
|
||||||
|
else if (worthLogging) {
|
||||||
missingCards.add(cis.name);
|
missingCards.add(cis.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(worthLogging) {
|
if (worthLogging) {
|
||||||
if(missingCards.isEmpty())
|
if (missingCards.isEmpty()) {
|
||||||
System.out.println(" ... 100% ");
|
System.out.println(" ... 100% ");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
int missing = (e.getCards().length - missingCards.size()) * 10000 / e.getCards().length;
|
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, " | ") );
|
System.out.printf(" ... %.2f%% (%s missing: %s )%n", missing * 0.01f, Lang.nounWithAmount(missingCards.size(), "card"), StringUtils.join(missingCards, " | ") );
|
||||||
@@ -122,9 +125,8 @@ public final class CardDb implements ICardDatabase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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, 0));
|
addCard(new PaperCard(cr, CardEdition.UNKNOWN.getCode(), CardRarity.Special, 0));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,6 @@ public class FModel {
|
|||||||
// this fills in our map of card names to Card instances.
|
// this fills in our map of card names to Card instances.
|
||||||
CardDb.setup(reader.loadCards(), editions);
|
CardDb.setup(reader.loadCards(), editions);
|
||||||
|
|
||||||
|
|
||||||
this.formats = new FormatCollection("res/blockdata/formats.txt");
|
this.formats = new FormatCollection("res/blockdata/formats.txt");
|
||||||
this.boosters = new StorageBase<SealedProductTemplate>("Boosters", editions.getBoosterGenerator());
|
this.boosters = new StorageBase<SealedProductTemplate>("Boosters", editions.getBoosterGenerator());
|
||||||
this.specialBoosters = new StorageBase<SealedProductTemplate>("Special boosters", new SealedProductTemplate.Reader("res/blockdata/boosters-special.txt"));
|
this.specialBoosters = new StorageBase<SealedProductTemplate>("Special boosters", new SealedProductTemplate.Reader("res/blockdata/boosters-special.txt"));
|
||||||
@@ -403,12 +402,9 @@ public class FModel {
|
|||||||
|
|
||||||
|
|
||||||
public GauntletMini getGauntletMini() {
|
public GauntletMini getGauntletMini() {
|
||||||
|
|
||||||
if (gauntlet == null) {
|
if (gauntlet == null) {
|
||||||
gauntlet = new GauntletMini();
|
gauntlet = new GauntletMini();
|
||||||
}
|
}
|
||||||
return gauntlet;
|
return gauntlet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user