mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Cards that were missing setInfo will be listed in a good errorviewer window.
This commit is contained in:
@@ -39,6 +39,8 @@ public final class CardDb {
|
||||
}
|
||||
}
|
||||
}
|
||||
private static List<String> skippedCards = new ArrayList<String>();
|
||||
public static List<String> getSkippedCards() { return skippedCards; }
|
||||
|
||||
// Here oracle cards
|
||||
private final Map<String, CardRules> cards = new Hashtable<String, CardRules>();
|
||||
@@ -61,13 +63,17 @@ public final class CardDb {
|
||||
|
||||
private CardDb(final Iterator<CardRules> parser) {
|
||||
while (parser.hasNext()) {
|
||||
addNewCard(parser.next());
|
||||
CardRules nextCard = parser.next();
|
||||
boolean wasAdded = addNewCard(nextCard);
|
||||
if (!wasAdded) {
|
||||
skippedCards.add(nextCard.getName());
|
||||
}
|
||||
}
|
||||
// TODO: consider using Collections.unmodifiableList wherever possible
|
||||
}
|
||||
|
||||
public void addNewCard(final CardRules card) {
|
||||
if (null == card) { return; }
|
||||
public boolean addNewCard(final CardRules card) {
|
||||
if (null == card) { return true; } // consider that a success
|
||||
//System.out.println(card.getName());
|
||||
String cardName = card.getName().toLowerCase();
|
||||
|
||||
@@ -95,7 +101,12 @@ public final class CardDb {
|
||||
cardCopies[i] = lastAdded;
|
||||
}
|
||||
}
|
||||
uniqueCards.put(cardName, lastAdded);
|
||||
|
||||
if (null != lastAdded) {
|
||||
uniqueCards.put(cardName, lastAdded);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Single fetch
|
||||
@@ -159,4 +170,14 @@ public final class CardDb {
|
||||
|
||||
public List<CardPrinted> getAllCards() { return allCardsFlat; }
|
||||
|
||||
|
||||
public class NoSetsException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = -8962691656197179214L;
|
||||
public final String cardName;
|
||||
public NoSetsException(String cardName) { this.cardName = cardName; }
|
||||
@Override public String toString() {
|
||||
return String.format("%s: The card '%s' was not assigned any set, it won't be loaded into game", this.getClass().getName(), cardName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.CardReader;
|
||||
@@ -79,6 +81,12 @@ public class PreloadingCardFactory extends AbstractCardFactory {
|
||||
// this fills in our map of card names to Card instances.
|
||||
read.run();
|
||||
CardDb.setup(listCardRules.iterator());
|
||||
|
||||
List<String> skipped = CardDb.getSkippedCards();
|
||||
if (!skipped.isEmpty()) {
|
||||
String message = String.format("The following cards are lacking of correct SetInfo: %s", StringUtils.join(skipped, ", "));
|
||||
ErrorViewer.showError(message);
|
||||
}
|
||||
} // readCard()
|
||||
|
||||
} //end class PreloadingCardFactory
|
||||
|
||||
Reference in New Issue
Block a user