mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
more resilent quest loader - handles situations like 'I took quest save from my friend who has all duel decks added to setdata.txt, and this quest fails to load on my machine dues to missing cards'
This commit is contained in:
@@ -150,14 +150,18 @@ public final class CardDb {
|
||||
}
|
||||
|
||||
public CardPrinted tryGetCard(final String cardName, String setName) {
|
||||
return tryGetCard(cardName, setName, 0);
|
||||
}
|
||||
|
||||
public CardPrinted tryGetCard(final String cardName, String setName, int index) {
|
||||
// Set exists?
|
||||
final Map<String, CardPrinted[]> cardsFromset = this.allCardsBySet.get(setName.toUpperCase());
|
||||
final Map<String, CardPrinted[]> cardsFromset = this.allCardsBySet.get(setName);
|
||||
if (cardsFromset == null) {
|
||||
return null;
|
||||
}
|
||||
// Card exists?
|
||||
final CardPrinted[] cardCopies = cardsFromset.get(cardName.toLowerCase());
|
||||
return cardCopies != null ? cardCopies[0] : null;
|
||||
final CardPrinted[] cardCopies = cardsFromset.get(cardName);
|
||||
return cardCopies != null && index < cardCopies.length ? cardCopies[index] : null;
|
||||
}
|
||||
|
||||
// Single fetch
|
||||
|
||||
@@ -669,8 +669,9 @@ public class QuestDataIO {
|
||||
final String sIndex = reader.getAttribute("i");
|
||||
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
||||
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
||||
final CardPrinted card = CardDb.instance().getCard(name, set, index);
|
||||
return foil ? CardPrinted.makeFoiled(card) : card;
|
||||
CardPrinted c = CardDb.instance().tryGetCard(name, set, index);
|
||||
if ( null == c ) c = CardDb.instance().getCard(name);
|
||||
return foil ? CardPrinted.makeFoiled(c) : c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user