diff --git a/forge-core/src/main/java/forge/StaticData.java b/forge-core/src/main/java/forge/StaticData.java index 3ebb8092dad..ace76500d2a 100644 --- a/forge-core/src/main/java/forge/StaticData.java +++ b/forge-core/src/main/java/forge/StaticData.java @@ -29,8 +29,6 @@ import java.util.stream.Collectors; public class StaticData { private final CardStorageReader cardReader; private final CardStorageReader tokenReader; - private final CardStorageReader customCardReader; - private final String blockDataFolder; private final CardDb commonCards; private final CardDb variantCards; @@ -79,7 +77,6 @@ public class StaticData { this.tokenReader = tokenReader; this.editions = new CardEdition.Collection(new CardEdition.Reader(new File(editionFolder))); this.blockDataFolder = blockDataFolder; - this.customCardReader = customCardReader; this.allowCustomCardsInDecksConformance = allowCustomCardsInDecksConformance; this.enableSmartCardArtSelection = enableSmartCardArtSelection; this.loadNonLegalCards = loadNonLegalCards; diff --git a/forge-core/src/main/java/forge/card/CardEdition.java b/forge-core/src/main/java/forge/card/CardEdition.java index dbf517b6bea..6d25f70a3c1 100644 --- a/forge-core/src/main/java/forge/card/CardEdition.java +++ b/forge-core/src/main/java/forge/card/CardEdition.java @@ -649,31 +649,37 @@ public final class CardEdition implements Comparable { continue; } - // parse sections of the format " " - if (editionSectionsWithCollectorNumbers.contains(sectionName)) { - for(String line : contents.get(sectionName)) { - Matcher matcher = pattern.matcher(line); - - if (!matcher.matches()) { - continue; - } - - String collectorNumber = matcher.group(2); - CardRarity r = CardRarity.smartValueOf(matcher.group(4)); - String cardName = matcher.group(5); - String artistName = matcher.group(7); - String functionalVariantName = matcher.group(9); - EditionEntry cis = new EditionEntry(cardName, collectorNumber, r, artistName, functionalVariantName); - - cardMap.put(sectionName, cis); - } - } else if (boosterSlotsToParse.contains(sectionName)) { - // parse booster slots of the format "Base=N\n|Replace= " - boosterSlots.add(BoosterSlot.parseSlot(sectionName, contents.get(sectionName))); + if (sectionName.endsWith("Types")) { + parseTypes(sectionName, contents.get(sectionName)); } else { - // save custom print sheets of the format " ||" - // to parse later when printsheets are loaded lazily (and the cardpool is already initialized) - customPrintSheetsToParse.put(sectionName, contents.get(sectionName)); + // Parse cards + + // parse sections of the format " " + if (editionSectionsWithCollectorNumbers.contains(sectionName)) { + for(String line : contents.get(sectionName)) { + Matcher matcher = pattern.matcher(line); + + if (!matcher.matches()) { + continue; + } + + String collectorNumber = matcher.group(2); + CardRarity r = CardRarity.smartValueOf(matcher.group(4)); + String cardName = matcher.group(5); + String artistName = matcher.group(7); + String functionalVariantName = matcher.group(9); + EditionEntry cis = new EditionEntry(cardName, collectorNumber, r, artistName, functionalVariantName); + + cardMap.put(sectionName, cis); + } + } else if (boosterSlotsToParse.contains(sectionName)) { + // parse booster slots of the format "Base=N\n|Replace= " + boosterSlots.add(BoosterSlot.parseSlot(sectionName, contents.get(sectionName))); + } else { + // save custom print sheets of the format " ||" + // to parse later when printsheets are loaded lazily (and the cardpool is already initialized) + customPrintSheetsToParse.put(sectionName, contents.get(sectionName)); + } } } @@ -819,6 +825,75 @@ public final class CardEdition implements Comparable { } public static final FilenameFilter TXT_FILE_FILTER = (dir, name) -> name.endsWith(".txt"); + + private void parseTypes(String sectionName, List content) { + Set 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 { diff --git a/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java b/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java index cec385ee502..6077429aa06 100644 --- a/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java +++ b/forge-gui/src/main/java/forge/localinstance/properties/ForgeConstants.java @@ -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_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_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 USER_ADVENTURE_DIR = USER_DIR + "adventure" + PATH_SEPARATOR; public static final String DECK_DRAFT_DIR = DECK_BASE_DIR + "draft" + PATH_SEPARATOR; diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index adc8c8464a2..251966fe856 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -59,7 +59,6 @@ import forge.util.storage.IStorage; import forge.util.storage.StorageBase; import java.io.File; -import java.io.FilenameFilter; import java.util.List; import java.util.Map; import java.util.Set; @@ -410,26 +409,6 @@ public final class FModel { 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 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(); }