mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Restrict Deck Editor cards
- fix duplicate cards
This commit is contained in:
@@ -37,6 +37,7 @@ public class StaticData {
|
||||
|
||||
private final String blockDataFolder;
|
||||
private final CardDb commonCards;
|
||||
private final CardDb commonCardsforDeckEditor;
|
||||
private final CardDb variantCards;
|
||||
private final CardDb customCards;
|
||||
private final TokenDb allTokens;
|
||||
@@ -108,11 +109,14 @@ public class StaticData {
|
||||
commonCards = new CardDb(regularCards, editions);
|
||||
variantCards = new CardDb(variantsCards, editions);
|
||||
customCards = new CardDb(customizedCards, customEditions);
|
||||
commonCardsforDeckEditor = new CardDb(regularCards, editions);
|
||||
|
||||
//must initialize after establish field values for the sake of card image logic
|
||||
commonCards.initialize(false, false, enableUnknownCards, loadNonLegalCards);
|
||||
variantCards.initialize(false, false, enableUnknownCards, loadNonLegalCards);
|
||||
customCards.initialize(false, false, enableUnknownCards, loadNonLegalCards);
|
||||
commonCards.initialize(false, false, enableUnknownCards, loadNonLegalCards, false);
|
||||
variantCards.initialize(false, false, enableUnknownCards, loadNonLegalCards, false);
|
||||
customCards.initialize(false, false, enableUnknownCards, loadNonLegalCards, false);
|
||||
//cannot filter commonCards unless we don't allow to put duplicate parts on database, commonCardsforDeckEditor is strictly for Deck Editor use
|
||||
commonCardsforDeckEditor.initialize(false, false, enableUnknownCards, loadNonLegalCards, true);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -129,8 +133,10 @@ public class StaticData {
|
||||
{
|
||||
if (customCards.getAllCards().size() > 0) {
|
||||
Collection<PaperCard> paperCards = customCards.getAllCards();
|
||||
for(PaperCard p: paperCards)
|
||||
for(PaperCard p: paperCards) {
|
||||
commonCards.addCard(p);
|
||||
commonCardsforDeckEditor.addCard(p, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,7 +245,13 @@ public class StaticData {
|
||||
}
|
||||
|
||||
public CardDb getCommonCards() {
|
||||
return commonCards;
|
||||
return getCommonCards(true);
|
||||
}
|
||||
|
||||
public CardDb getCommonCards(boolean includeBackSides) {
|
||||
if (includeBackSides)
|
||||
return commonCards;
|
||||
return commonCardsforDeckEditor;
|
||||
}
|
||||
|
||||
public CardDb getCustomCards() {
|
||||
|
||||
@@ -156,6 +156,9 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
|
||||
private void addSetCard(CardEdition e, CardInSet cis, CardRules cr) {
|
||||
addSetCard(e, cis, cr, false);
|
||||
}
|
||||
private void addSetCard(CardEdition e, CardInSet cis, CardRules cr, boolean noSplitTypesNames) {
|
||||
int artIdx = 1;
|
||||
String key = e.getCode() + "/" + cis.name;
|
||||
if (artIds.containsKey(key)) {
|
||||
@@ -163,7 +166,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
|
||||
artIds.put(key, artIdx);
|
||||
addCard(new PaperCard(cr, e.getCode(), cis.rarity, artIdx));
|
||||
addCard(new PaperCard(cr, e.getCode(), cis.rarity, artIdx), noSplitTypesNames);
|
||||
}
|
||||
|
||||
public void loadCard(String cardName, CardRules cr) {
|
||||
@@ -182,7 +185,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
reIndex();
|
||||
}
|
||||
|
||||
public void initialize(boolean logMissingPerEdition, boolean logMissingSummary, boolean enableUnknownCards, boolean loadNonLegalCards) {
|
||||
public void initialize(boolean logMissingPerEdition, boolean logMissingSummary, boolean enableUnknownCards, boolean loadNonLegalCards, boolean noSplitTypesNames) {
|
||||
Set<String> allMissingCards = new LinkedHashSet<>();
|
||||
List<String> missingCards = new ArrayList<>();
|
||||
CardEdition upcomingSet = null;
|
||||
@@ -210,7 +213,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
|
||||
if (cr != null) {
|
||||
addSetCard(e, cis, cr);
|
||||
addSetCard(e, cis, cr, noSplitTypesNames);
|
||||
}
|
||||
else {
|
||||
missingCards.add(cis.name);
|
||||
@@ -255,8 +258,13 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
}
|
||||
|
||||
public void addCard(PaperCard paperCard) {
|
||||
addCard(paperCard, false);
|
||||
}
|
||||
public void addCard(PaperCard paperCard, boolean noSplitTypesNames) {
|
||||
allCardsByName.put(paperCard.getName(), paperCard);
|
||||
|
||||
if (noSplitTypesNames) { return; }
|
||||
|
||||
if (paperCard.getRules().getSplitType() == CardSplitType.None) { return; }
|
||||
|
||||
if (paperCard.getRules().getOtherPart() != null) {
|
||||
|
||||
Reference in New Issue
Block a user