mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +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.card.CardDb.CardRequest;
|
||||||
import forge.item.BoosterBox;
|
import forge.item.BoosterBox;
|
||||||
import forge.item.FatPack;
|
import forge.item.FatPack;
|
||||||
|
import forge.item.PaperCard;
|
||||||
import forge.item.SealedProduct;
|
import forge.item.SealedProduct;
|
||||||
import forge.util.storage.IStorage;
|
import forge.util.storage.IStorage;
|
||||||
import forge.util.storage.StorageBase;
|
import forge.util.storage.StorageBase;
|
||||||
@@ -96,6 +97,21 @@ public class StaticData {
|
|||||||
return sortedEditions;
|
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) {
|
public void attemptToLoadCard(String encodedCardName, String setCode) {
|
||||||
CardDb.CardRequest r = CardRequest.fromString(encodedCardName);
|
CardDb.CardRequest r = CardRequest.fromString(encodedCardName);
|
||||||
String cardName = r.cardName;
|
String cardName = r.cardName;
|
||||||
|
|||||||
@@ -185,19 +185,11 @@ public class GauntletIO {
|
|||||||
final String sIndex = reader.getAttribute("i");
|
final String sIndex = reader.getAttribute("i");
|
||||||
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
||||||
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
||||||
PaperCard card = FModel.getMagicDb().getCommonCards().getCard(name, set, index);
|
PaperCard card = FModel.getMagicDb().getOrLoadCommonCard(name, set, index, foil);
|
||||||
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);
|
|
||||||
}
|
|
||||||
if (null == card) {
|
if (null == card) {
|
||||||
throw new RuntimeException("Unsupported card found in quest save: " + name + " from edition " + set);
|
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 String sIndex = reader.getAttribute("i");
|
||||||
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
||||||
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
||||||
PaperCard c = FModel.getMagicDb().getCommonCards().getCard(name, set, index);
|
PaperCard card = FModel.getMagicDb().getOrLoadCommonCard(name, set, index, foil);
|
||||||
if ( null == c ) c = FModel.getMagicDb().getCommonCards().getCard(name);
|
if (null == card) {
|
||||||
return foil ? FModel.getMagicDb().getCommonCards().getFoiled(c) : c;
|
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 String sIndex = reader.getAttribute("i");
|
||||||
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
|
||||||
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
final boolean foil = "1".equals(reader.getAttribute("foil"));
|
||||||
PaperCard card = FModel.getMagicDb().getCommonCards().getCard(name, set, index);
|
PaperCard card = FModel.getMagicDb().getOrLoadCommonCard(name, set, index, foil);
|
||||||
if (null == card) {
|
|
||||||
card = FModel.getMagicDb().getCommonCards().getCard(name, set, -1);
|
|
||||||
}
|
|
||||||
if (null == card) {
|
if (null == card) {
|
||||||
throw new RuntimeException("Unsupported card found in quest save: " + name + " from edition " + set);
|
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