mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
Move custom types into edition files
This commit is contained in:
@@ -29,8 +29,6 @@ import java.util.stream.Collectors;
|
|||||||
public class StaticData {
|
public class StaticData {
|
||||||
private final CardStorageReader cardReader;
|
private final CardStorageReader cardReader;
|
||||||
private final CardStorageReader tokenReader;
|
private final CardStorageReader tokenReader;
|
||||||
private final CardStorageReader customCardReader;
|
|
||||||
|
|
||||||
private final String blockDataFolder;
|
private final String blockDataFolder;
|
||||||
private final CardDb commonCards;
|
private final CardDb commonCards;
|
||||||
private final CardDb variantCards;
|
private final CardDb variantCards;
|
||||||
@@ -79,7 +77,6 @@ public class StaticData {
|
|||||||
this.tokenReader = tokenReader;
|
this.tokenReader = tokenReader;
|
||||||
this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder)));
|
this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder)));
|
||||||
this.blockDataFolder = blockDataFolder;
|
this.blockDataFolder = blockDataFolder;
|
||||||
this.customCardReader = customCardReader;
|
|
||||||
this.allowCustomCardsInDecksConformance = allowCustomCardsInDecksConformance;
|
this.allowCustomCardsInDecksConformance = allowCustomCardsInDecksConformance;
|
||||||
this.enableSmartCardArtSelection = enableSmartCardArtSelection;
|
this.enableSmartCardArtSelection = enableSmartCardArtSelection;
|
||||||
this.loadNonLegalCards = loadNonLegalCards;
|
this.loadNonLegalCards = loadNonLegalCards;
|
||||||
|
|||||||
@@ -649,6 +649,11 @@ public final class CardEdition implements Comparable<CardEdition> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sectionName.endsWith("Types")) {
|
||||||
|
parseTypes(sectionName, contents.get(sectionName));
|
||||||
|
} else {
|
||||||
|
// Parse cards
|
||||||
|
|
||||||
// parse sections of the format "<collector number> <rarity> <name>"
|
// parse sections of the format "<collector number> <rarity> <name>"
|
||||||
if (editionSectionsWithCollectorNumbers.contains(sectionName)) {
|
if (editionSectionsWithCollectorNumbers.contains(sectionName)) {
|
||||||
for(String line : contents.get(sectionName)) {
|
for(String line : contents.get(sectionName)) {
|
||||||
@@ -676,6 +681,7 @@ public final class CardEdition implements Comparable<CardEdition> {
|
|||||||
customPrintSheetsToParse.put(sectionName, contents.get(sectionName));
|
customPrintSheetsToParse.put(sectionName, contents.get(sectionName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ListMultimap<String, EditionEntry> tokenMap = ArrayListMultimap.create();
|
ListMultimap<String, EditionEntry> tokenMap = ArrayListMultimap.create();
|
||||||
ListMultimap<String, EditionEntry> otherMap = ArrayListMultimap.create();
|
ListMultimap<String, EditionEntry> otherMap = ArrayListMultimap.create();
|
||||||
@@ -819,6 +825,75 @@ public final class CardEdition implements Comparable<CardEdition> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final FilenameFilter TXT_FILE_FILTER = (dir, name) -> name.endsWith(".txt");
|
public static final FilenameFilter TXT_FILE_FILTER = (dir, name) -> name.endsWith(".txt");
|
||||||
|
|
||||||
|
private void parseTypes(String sectionName, List<String> content) {
|
||||||
|
Set<String> addToSection = null;
|
||||||
|
|
||||||
|
switch (sectionName) {
|
||||||
|
case "BasicType":
|
||||||
|
addToSection = CardType.Constant.BASIC_TYPES;
|
||||||
|
break;
|
||||||
|
case "LandTypes":
|
||||||
|
addToSection = CardType.Constant.LAND_TYPES;
|
||||||
|
break;
|
||||||
|
case "CreatureTypes":
|
||||||
|
addToSection = CardType.Constant.CREATURE_TYPES;
|
||||||
|
break;
|
||||||
|
case "SpellTypes":
|
||||||
|
addToSection = CardType.Constant.SPELL_TYPES;
|
||||||
|
break;
|
||||||
|
case "EnchantmentTypes":
|
||||||
|
addToSection = CardType.Constant.ENCHANTMENT_TYPES;
|
||||||
|
break;
|
||||||
|
case "ArtifactTypes":
|
||||||
|
addToSection = CardType.Constant.ARTIFACT_TYPES;
|
||||||
|
break;
|
||||||
|
case "WalkerTypes":
|
||||||
|
addToSection = CardType.Constant.WALKER_TYPES;
|
||||||
|
break;
|
||||||
|
case "DungeonTypes":
|
||||||
|
addToSection = CardType.Constant.DUNGEON_TYPES;
|
||||||
|
break;
|
||||||
|
case "BattleTypes":
|
||||||
|
addToSection = CardType.Constant.BATTLE_TYPES;
|
||||||
|
break;
|
||||||
|
case "PlanarTypes":
|
||||||
|
addToSection = CardType.Constant.PLANAR_TYPES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addToSection == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String line : content) {
|
||||||
|
if (line.length() == 0) continue;
|
||||||
|
|
||||||
|
if (line.contains(":")) {
|
||||||
|
String[] k = line.split(":");
|
||||||
|
|
||||||
|
if (addToSection.contains(k[0])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
addToSection.add(k[0]);
|
||||||
|
CardType.Constant.pluralTypes.put(k[0], k[1]);
|
||||||
|
|
||||||
|
if (k[0].contains(" ")) {
|
||||||
|
CardType.Constant.MultiwordTypes.add(k[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (addToSection.contains(line)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
addToSection.add(line);
|
||||||
|
if (line.contains(" ")) {
|
||||||
|
CardType.Constant.MultiwordTypes.add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Collection extends StorageBase<CardEdition> {
|
public static class Collection extends StorageBase<CardEdition> {
|
||||||
|
|||||||
@@ -249,7 +249,6 @@ public final class ForgeConstants {
|
|||||||
public static final String USER_CUSTOM_CARDS_DIR = USER_CUSTOM_DIR + "cards" + PATH_SEPARATOR;
|
public static final String USER_CUSTOM_CARDS_DIR = USER_CUSTOM_DIR + "cards" + PATH_SEPARATOR;
|
||||||
public static final String USER_CUSTOM_TOKENS_DIR = USER_CUSTOM_DIR + "tokens" + PATH_SEPARATOR;
|
public static final String USER_CUSTOM_TOKENS_DIR = USER_CUSTOM_DIR + "tokens" + PATH_SEPARATOR;
|
||||||
public static final String USER_FORMATS_DIR = USER_CUSTOM_DIR + "formats" + PATH_SEPARATOR;
|
public static final String USER_FORMATS_DIR = USER_CUSTOM_DIR + "formats" + PATH_SEPARATOR;
|
||||||
public static final String USER_CUSTOM_TYPE_LIST_DIR = USER_CUSTOM_DIR + "typelists" + PATH_SEPARATOR;
|
|
||||||
public static final String CUSTOM_STARTER_DECK_DIR = USER_CUSTOM_DIR + "starterdecks" + PATH_SEPARATOR;
|
public static final String CUSTOM_STARTER_DECK_DIR = USER_CUSTOM_DIR + "starterdecks" + PATH_SEPARATOR;
|
||||||
public static final String USER_ADVENTURE_DIR = USER_DIR + "adventure" + PATH_SEPARATOR;
|
public static final String USER_ADVENTURE_DIR = USER_DIR + "adventure" + PATH_SEPARATOR;
|
||||||
public static final String DECK_DRAFT_DIR = DECK_BASE_DIR + "draft" + PATH_SEPARATOR;
|
public static final String DECK_DRAFT_DIR = DECK_BASE_DIR + "draft" + PATH_SEPARATOR;
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ import forge.util.storage.IStorage;
|
|||||||
import forge.util.storage.StorageBase;
|
import forge.util.storage.StorageBase;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -410,26 +409,6 @@ public final class FModel {
|
|||||||
|
|
||||||
loadTypes(typeListFile);
|
loadTypes(typeListFile);
|
||||||
|
|
||||||
File customTypesFilesDir = new File(ForgeConstants.USER_CUSTOM_TYPE_LIST_DIR);
|
|
||||||
if (customTypesFilesDir.exists() && customTypesFilesDir.isDirectory()) {
|
|
||||||
File[] txtFiles = customTypesFilesDir.listFiles(new FilenameFilter() {
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.toLowerCase().endsWith(".txt");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (txtFiles != null) {
|
|
||||||
for (File file : txtFiles) {
|
|
||||||
try {
|
|
||||||
final List<String> customTypeListFile = FileUtil.readFile(file);
|
|
||||||
loadTypes(customTypeListFile);
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Failed to load custom types from file " + file.getAbsolutePath());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CardType.Constant.LOADED.set();
|
CardType.Constant.LOADED.set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user