mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Fix more places to load cards lazily correctly.
This commit is contained in:
@@ -7,6 +7,7 @@ import forge.card.PrintSheet;
|
||||
import forge.card.CardDb.CardRequest;
|
||||
import forge.item.BoosterBox;
|
||||
import forge.item.FatPack;
|
||||
import forge.item.PaperCard;
|
||||
import forge.item.SealedProduct;
|
||||
import forge.util.storage.IStorage;
|
||||
import forge.util.storage.StorageBase;
|
||||
@@ -96,6 +97,21 @@ public class StaticData {
|
||||
return sortedEditions;
|
||||
}
|
||||
|
||||
public PaperCard getOrLoadCommonCard(String cardName, String setCode, int artIndex, boolean foil) {
|
||||
PaperCard card = commonCards.getCard(cardName, setCode, artIndex);
|
||||
if (card == null) {
|
||||
attemptToLoadCard(cardName, setCode);
|
||||
commonCards.getCard(cardName, setCode, artIndex);
|
||||
}
|
||||
if (card == null) {
|
||||
card = commonCards.getCard(cardName, setCode, -1);
|
||||
}
|
||||
if (card == null) {
|
||||
return null;
|
||||
}
|
||||
return foil ? commonCards.getFoiled(card) : card;
|
||||
}
|
||||
|
||||
public void attemptToLoadCard(String encodedCardName, String setCode) {
|
||||
CardDb.CardRequest r = CardRequest.fromString(encodedCardName);
|
||||
String cardName = r.cardName;
|
||||
|
||||
@@ -185,19 +185,11 @@ public class GauntletIO {
|
||||
final String sIndex = reader.getAttribute("i");
|
||||
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
||||
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
||||
PaperCard card = FModel.getMagicDb().getCommonCards().getCard(name, set, index);
|
||||
if (null == card) {
|
||||
FModel.getMagicDb().attemptToLoadCard(name, set);
|
||||
card = FModel.getMagicDb().getCommonCards().getCard(name, set, index);
|
||||
}
|
||||
if (null == card) {
|
||||
FModel.getMagicDb().attemptToLoadCard(name, set);
|
||||
card = FModel.getMagicDb().getCommonCards().getCard(name, set, -1);
|
||||
}
|
||||
PaperCard card = FModel.getMagicDb().getOrLoadCommonCard(name, set, index, foil);
|
||||
if (null == card) {
|
||||
throw new RuntimeException("Unsupported card found in quest save: " + name + " from edition " + set);
|
||||
}
|
||||
return foil ? FModel.getMagicDb().getCommonCards().getFoiled(card) : card;
|
||||
return card;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -897,9 +897,11 @@ 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"));
|
||||
PaperCard c = FModel.getMagicDb().getCommonCards().getCard(name, set, index);
|
||||
if ( null == c ) c = FModel.getMagicDb().getCommonCards().getCard(name);
|
||||
return foil ? FModel.getMagicDb().getCommonCards().getFoiled(c) : c;
|
||||
PaperCard card = FModel.getMagicDb().getOrLoadCommonCard(name, set, index, foil);
|
||||
if (null == card) {
|
||||
throw new RuntimeException("Unsupported card found in quest save: " + name + " from edition " + set);
|
||||
}
|
||||
return card;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,14 +177,11 @@ public class TournamentIO {
|
||||
final String sIndex = reader.getAttribute("i");
|
||||
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
||||
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
||||
PaperCard card = FModel.getMagicDb().getCommonCards().getCard(name, set, index);
|
||||
if (null == card) {
|
||||
card = FModel.getMagicDb().getCommonCards().getCard(name, set, -1);
|
||||
}
|
||||
PaperCard card = FModel.getMagicDb().getOrLoadCommonCard(name, set, index, foil);
|
||||
if (null == card) {
|
||||
throw new RuntimeException("Unsupported card found in quest save: " + name + " from edition " + set);
|
||||
}
|
||||
return foil ? FModel.getMagicDb().getCommonCards().getFoiled(card) : card;
|
||||
return card;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user