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