mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
allow ALL cards to be (de)serialized
This is needed by network play variants like: - Vanguard - Planechase Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
This commit is contained in:
@@ -29,6 +29,7 @@ public class StaticData {
|
|||||||
private final String blockDataFolder;
|
private final String blockDataFolder;
|
||||||
private final CardDb commonCards;
|
private final CardDb commonCards;
|
||||||
private final CardDb variantCards;
|
private final CardDb variantCards;
|
||||||
|
private final CardDb allCards;
|
||||||
private final TokenDb allTokens;
|
private final TokenDb allTokens;
|
||||||
private final CardEdition.Collection editions;
|
private final CardEdition.Collection editions;
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ public class StaticData {
|
|||||||
lastInstance = this;
|
lastInstance = this;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
final Map<String, CardRules> allCardsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
final Map<String, CardRules> regularCards = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
final Map<String, CardRules> regularCards = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
final Map<String, CardRules> variantsCards = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
final Map<String, CardRules> variantsCards = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@ public class StaticData {
|
|||||||
if (null == card) continue;
|
if (null == card) continue;
|
||||||
|
|
||||||
final String cardName = card.getName();
|
final String cardName = card.getName();
|
||||||
|
allCardsMap.put(cardName, card);
|
||||||
if (card.isVariant()) {
|
if (card.isVariant()) {
|
||||||
variantsCards.put(cardName, card);
|
variantsCards.put(cardName, card);
|
||||||
} else {
|
} else {
|
||||||
@@ -68,10 +71,12 @@ public class StaticData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allCards = new CardDb(allCardsMap, editions);
|
||||||
commonCards = new CardDb(regularCards, editions);
|
commonCards = new CardDb(regularCards, editions);
|
||||||
variantCards = new CardDb(variantsCards, editions);
|
variantCards = new CardDb(variantsCards, editions);
|
||||||
|
|
||||||
//muse initialize after establish field values for the sake of card image logic
|
//must initialize after establish field values for the sake of card image logic
|
||||||
|
allCards.initialize(false, false);
|
||||||
commonCards.initialize(false, false);
|
commonCards.initialize(false, false);
|
||||||
variantCards.initialize(false, false);
|
variantCards.initialize(false, false);
|
||||||
}
|
}
|
||||||
@@ -184,6 +189,8 @@ public class StaticData {
|
|||||||
return variantCards;
|
return variantCards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CardDb getAllCards() { return allCards; }
|
||||||
|
|
||||||
public TokenDb getAllTokens() { return allTokens; }
|
public TokenDb getAllTokens() { return allTokens; }
|
||||||
|
|
||||||
public PaperCard getCardByEditionDate(PaperCard card, Date editionDate) {
|
public PaperCard getCardByEditionDate(PaperCard card, Date editionDate) {
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public final class PaperCard implements Comparable<IPaperCard>, InventoryItemFro
|
|||||||
// default deserialization
|
// default deserialization
|
||||||
ois.defaultReadObject();
|
ois.defaultReadObject();
|
||||||
|
|
||||||
final IPaperCard pc = StaticData.instance().getCommonCards().getCard(name, edition, artIndex);
|
final IPaperCard pc = StaticData.instance().getAllCards().getCard(name, edition, artIndex);
|
||||||
if (pc == null) {
|
if (pc == null) {
|
||||||
throw new IOException(TextUtil.concatWithSpace("Card", name, "not found"));
|
throw new IOException(TextUtil.concatWithSpace("Card", name, "not found"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user