mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Pulled all the deck loading errors together.
This commit is contained in:
@@ -102,9 +102,9 @@ public final class CardDb {
|
||||
public CardPrinted getCard(final String name) {
|
||||
// Sometimes they read from decks things like "CardName|Set" - but we can handle it
|
||||
int pipePos = name.indexOf('|');
|
||||
String cardName = name.toLowerCase();
|
||||
String cardName = name;
|
||||
if (pipePos >= 0) {
|
||||
cardName = name.substring(0, pipePos).toLowerCase();
|
||||
cardName = name.substring(0, pipePos);
|
||||
String setName = name.substring(pipePos + 1);
|
||||
// only if set is not blank try to load it
|
||||
if (StringUtils.isNotBlank(setName)) {
|
||||
@@ -112,7 +112,7 @@ public final class CardDb {
|
||||
}
|
||||
}
|
||||
// OK, plain name here
|
||||
CardPrinted card = uniqueCards.get(cardName);
|
||||
CardPrinted card = uniqueCards.get(cardName.toLowerCase());
|
||||
if (card != null) { return card; }
|
||||
throw new NoSuchElementException(String.format("Card '%s' not found in our database.", name));
|
||||
}
|
||||
|
||||
@@ -220,17 +220,21 @@ public class DeckManager {
|
||||
|
||||
File[] files;
|
||||
|
||||
List<String> decksThatFailedToLoad = new ArrayList<String>();
|
||||
files = deckDir.listFiles(DCKFileFilter);
|
||||
for (File file : files) {
|
||||
|
||||
try {
|
||||
Deck newDeck = readDeck(file);
|
||||
deckMap.put(newDeck.getName(), newDeck);
|
||||
} catch ( NoSuchElementException ex ) {
|
||||
String message = String.format("Your deck '%s' failed to load beacuse %s", file.getName(), ex.getMessage());
|
||||
JOptionPane.showMessageDialog(null, message, "One of your decks failed to load", JOptionPane.ERROR_MESSAGE);
|
||||
} catch (NoSuchElementException ex) {
|
||||
String message = String.format("%s failed to load because ---- %s", file.getName(), ex.getMessage());
|
||||
decksThatFailedToLoad.add(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!decksThatFailedToLoad.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(null, StringUtils.join(decksThatFailedToLoad, System.getProperty("line.separator")),
|
||||
"Some of your decks were not loaded.", JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
|
||||
files = deckDir.listFiles(BDKFileFilter);
|
||||
|
||||
Reference in New Issue
Block a user