diff --git a/forge-game/src/main/java/forge/game/GameFormat.java b/forge-game/src/main/java/forge/game/GameFormat.java index 243ad9e4321..e4941a1d7b3 100644 --- a/forge-game/src/main/java/forge/game/GameFormat.java +++ b/forge-game/src/main/java/forge/game/GameFormat.java @@ -32,16 +32,20 @@ import forge.deck.Deck; import forge.item.IPaperCard; import forge.item.PaperCard; import forge.util.FileSection; +import forge.util.FileUtil; import forge.util.storage.StorageBase; import forge.util.storage.StorageReaderFileSections; +import forge.util.storage.StorageReaderFolder; import java.io.File; +import java.io.FilenameFilter; import java.util.*; import java.util.Map.Entry; public class GameFormat implements Comparable { private final String name; + private final Boolean isCore; // contains allowed sets, when empty allows all sets protected final List allowedSetCodes; // this is mutable to support quest mode set unlocks @@ -59,14 +63,15 @@ public class GameFormat implements Comparable { private final int index; public GameFormat(final String fName, final Iterable sets, final List bannedCards) { - this(fName, sets, bannedCards, null, null, 0); + this(fName, sets, bannedCards, null, null, 0, false); } - public static final GameFormat NoFormat = new GameFormat("(none)", null, null, null, null, Integer.MAX_VALUE); + public static final GameFormat NoFormat = new GameFormat("(none)", null, null, null, null, Integer.MAX_VALUE, false); public GameFormat(final String fName, final Iterable sets, final List bannedCards, - final List restrictedCards, final List rarities, int compareIdx) { + final List restrictedCards, final List rarities, int compareIdx, Boolean isCore) { this.index = compareIdx; + this.isCore = isCore; this.name = fName; allowedSetCodes = sets == null ? new ArrayList() : Lists.newArrayList(sets); bannedCardNames = bannedCards == null ? new ArrayList() : Lists.newArrayList(bannedCards); @@ -109,6 +114,10 @@ public class GameFormat implements Comparable { return this.name; } + public Boolean isCore() { + return this.isCore; + } + public List getAllowedSetCodes() { return this.allowedSetCodes_ro; } @@ -199,7 +208,7 @@ public class GameFormat implements Comparable { return index; } - public static class Reader extends StorageReaderFileSections { + public static class Reader extends StorageReaderFolder { List naturallyOrdered = new ArrayList(); public Reader(File file0) { @@ -207,12 +216,16 @@ public class GameFormat implements Comparable { } @Override - protected GameFormat read(String title, Iterable body, int idx) { + protected GameFormat read(File file) { + final Map> contents = FileSection.parseSections(FileUtil.readFile(file)); List sets = null; // default: all sets allowed List bannedCards = null; // default: nothing banned List restrictedCards = null; // default: nothing restricted List rarities = null; - FileSection section = FileSection.parse(body, ":"); + FileSection section = FileSection.parse(contents.get("format"), ":"); + String title = section.get("name"); + Boolean isCore = section.getBoolean("core"); + Integer idx = section.getInt("order"); String strSets = section.get("sets"); if ( null != strSets ) { sets = Arrays.asList(strSets.split(", ")); @@ -239,10 +252,22 @@ public class GameFormat implements Comparable { } } - GameFormat result = new GameFormat(title, sets, bannedCards, restrictedCards, rarities, 1 + idx); + GameFormat result = new GameFormat(title, sets, bannedCards, restrictedCards, rarities, idx, isCore); naturallyOrdered.add(result); return result; } + + @Override + protected FilenameFilter getFileFilter() { + return TXT_FILE_FILTER; + } + + public static final FilenameFilter TXT_FILE_FILTER = new FilenameFilter() { + @Override + public boolean accept(final File dir, final String name) { + return name.endsWith(".txt"); + } + }; } public static class Collection extends StorageBase { @@ -251,12 +276,23 @@ public class GameFormat implements Comparable { public Collection(GameFormat.Reader reader) { super("Format collections", reader); naturallyOrdered = reader.naturallyOrdered; + Collections.sort(naturallyOrdered); } public Iterable getOrderedList() { return naturallyOrdered; } + public Iterable getCoreList() { + List coreList = new ArrayList<>(); + for(GameFormat format: naturallyOrdered){ + if(format.isCore()){ + coreList.add(format); + } + } + return coreList; + } + public GameFormat getStandard() { return this.map.get("Standard"); } diff --git a/forge-gui/res/formats/Commander.txt b/forge-gui/res/formats/Commander.txt new file mode 100644 index 00000000000..5fef633dc46 --- /dev/null +++ b/forge-gui/res/formats/Commander.txt @@ -0,0 +1,4 @@ +[format] +Name:Commander +Order:106 +Banned:Adriana's Valor; Advantageous Proclamation; Ashnod's Coupon; Assemble the Rank and Vile; Backup Plan; Brago's Favor; Double Cross; Double Deal; Double Dip; Double Play; Double Stroke; Double Take; Echoing Boon; Emissary's Ploy; Enter the Dungeon; Hired Heist; Hold the Perimeter; Hymn of the Wilds; Immediate Action; Incendiary Dissent; Iterative Analysis; Magical Hacker; Mox Lotus; Muzzio's Preparations; Natural Unity; Once More with Feeling; Power Play; R&D's Secret Lair; Richard Garfield, Ph.D.; Secret Summoning; Secrets of Paradise; Sentinel Dispatch; Sovereign's Realm; Staying Power; Summoner's Bond; Time Machine; Unexpected Potential; Weight Advantage; Worldknit; Amulet of Quoz; Bronze Tablet; Contract from Below; Darkpact; Demonic Attorney; Jeweled Bird; Rebirth; Tempest Efreet; Timmerian Fiends; Ancestral Recall; Balance; Biorhythm; Black Lotus; Braids, Cabal Minion; Chaos Orb; Coalition Victory; Channel; Emrakul, the Aeons Torn; Erayo, Soratami Ascendant; Falling Star; Fastbond; Gifts Ungiven; Griselbrand; Karakas; Leovold, Emissary of Trest; Library of Alexandria; Limited Resources; Mox Emerald; Mox Jet; Mox Pearl; Mox Ruby; Mox Sapphire; Painter's Servant; Panoptic Mirror; Primeval Titan; Prophet of Kruphix; Recurring Nightmare; Rofellos, Llanowar Emissary; Shahrazad; Staying Power; Sundering Titan; Sway of the Stars; Sylvan Primordial; Time Machine; Time Vault; Time Walk; Tinker; Tolarian Academy; Trade Secrets; Upheaval; Worldfire; Yawgmoth's Bargain diff --git a/forge-gui/res/formats/Extended.txt b/forge-gui/res/formats/Extended.txt new file mode 100644 index 00000000000..340af95fcea --- /dev/null +++ b/forge-gui/res/formats/Extended.txt @@ -0,0 +1,6 @@ +[format] +Name:Extended +Order:107 +Core:true +Sets:SOM, MBS, NPH, M12, ISD, DKA, AVR, M13, RTR, GTC, DGM, M14, THS, BNG, JOU, M15 +Banned:Ponder; Mental Misstep diff --git a/forge-gui/res/formats/Kaladesh_Block.txt b/forge-gui/res/formats/Kaladesh_Block.txt new file mode 100644 index 00000000000..1a99dffb20a --- /dev/null +++ b/forge-gui/res/formats/Kaladesh_Block.txt @@ -0,0 +1,5 @@ +[format] +Name:Kaladesh Block +Order:109 +Core:true +Sets:KLD, AER \ No newline at end of file diff --git a/forge-gui/res/formats/Legacy.txt b/forge-gui/res/formats/Legacy.txt new file mode 100644 index 00000000000..3d1b710299e --- /dev/null +++ b/forge-gui/res/formats/Legacy.txt @@ -0,0 +1,5 @@ +[format] +Name:Legacy +Order:105 +Core:true +Banned:Adriana's Valor; Advantageous Proclamation; Assemble the Rank and Vile; Backup Plan; Brago's Favor; Double Stroke; Echoing Boon; Emissary's Ploy; Hired Heist; Hold the Perimeter; Hymn of the Wilds; Immediate Action; Incendiary Dissent; Iterative Analysis; Muzzio's Preparations; Natural Unity; Power Play; Secret Summoning; Secrets of Paradise; Sentinel Dispatch; Sovereign's Realm; Summoner's Bond; Unexpected Potential; Weight Advantage; Worldknit; Amulet of Quoz; Bronze Tablet; Contract from Below; Darkpact; Demonic Attorney; Jeweled Bird; Rebirth; Tempest Efreet; Timmerian Fiends; Ancestral Recall; Balance; Bazaar of Baghdad; Black Lotus; Channel; Chaos Orb; Demonic Consultation; Demonic Tutor; Dig Through Time; Earthcraft; Falling Star; Fastbond; Flash; Frantic Search; Goblin Recruiter; Gush; Hermit Druid; Imperial Seal; Library of Alexandria; Mana Crypt; Mana Drain; Mana Vault; Memory Jar; Mental Misstep; Mind Twist; Mind's Desire; Mishra's Workshop; Mox Emerald; Mox Jet; Mox Pearl; Mox Ruby; Mox Sapphire; Mystical Tutor; Necropotence; Oath of Druids; Sensei's Divining Top; Shahrazad; Skullclamp; Sol Ring; Strip Mine; Survival of the Fittest; Time Vault; Time Walk; Timetwister; Tinker; Tolarian Academy; Treasure Cruise; Vampiric Tutor; Wheel of Fortune; Windfall; Yawgmoth's Bargain; Yawgmoth's Will diff --git a/forge-gui/res/formats/Modern.txt b/forge-gui/res/formats/Modern.txt new file mode 100644 index 00000000000..3ccbe58347b --- /dev/null +++ b/forge-gui/res/formats/Modern.txt @@ -0,0 +1,6 @@ +[format] +Name:Modern +Order:102 +Core:true +Sets:8ED, MRD, DST, 5DN, CHK, BOK, SOK, 9ED, RAV, GPT, DIS, CSP, TSP, TSB, PLC, FUT, 10E, LRW, EVE, SHM, MOR, ALA, CFX, ARB, M10, ZEN, WWK, ROE, M11, SOM, MBS, NPH, M12, ISD, DKA, AVR, M13, RTR, GTC, DGM, M14, THS, BNG, JOU, M15, KTK, FRF, DTK, MM2, ORI, BFZ, OGW, SOI, EMN, KLD, AER, AKH, W17, HOU, XLN, RIX +Banned:Ancient Den; Birthing Pod; Blazing Shoal; Chrome Mox; Cloudpost; Dark Depths; Deathrite Shaman; Dig Through Time; Dread Return; Eye of Ugin; Gitaxian Probe; Glimpse of Nature; Golgari Grave-Troll; Great Furnace; Green Sun's Zenith; Hypergenesis; Mental Misstep; Ponder; Preordain; Punishing Fire; Rite of Flame; Seat of the Synod; Second Sunrise; Seething Song; Sensei's Divining Top; Skullclamp; Splinter Twin; Stoneforge Mystic; Summer Bloom; Treasure Cruise; Tree of Tales; Umezawa's Jitte; Vault of Whispers diff --git a/forge-gui/res/formats/Vintage.txt b/forge-gui/res/formats/Vintage.txt new file mode 100644 index 00000000000..eee31b2c25e --- /dev/null +++ b/forge-gui/res/formats/Vintage.txt @@ -0,0 +1,7 @@ +[format] +Name:Vintage +Order:104 +Core:true +Banned:Adriana's Valor; Advantageous Proclamation; Assemble the Rank and Vile; Backup Plan; Brago's Favor; Double Stroke; Echoing Boon; Emissary's Ploy; Hired Heist; Hold the Perimeter; Hymn of the Wilds; Immediate Action; Incendiary Dissent; Iterative Analysis; Muzzio's Preparations; Natural Unity; Power Play; Secret Summoning; Secrets of Paradise; Sentinel Dispatch; Sovereign's Realm; Summoner's Bond; Unexpected Potential; Weight Advantage; Worldknit; Amulet of Quoz; Bronze Tablet; Contract from Below; Darkpact; Demonic Attorney; Jeweled Bird; Rebirth; Tempest Efreet; Timmerian Fiends; Chaos Orb; Falling Star; Shahrazad +Restricted:Ancestral Recall; Balance; Black Lotus; Brainstorm; Chalice of the Void; Channel; Demonic Consultation; Demonic Tutor; Dig Through Time; Fastbond; Flash; Gitaxian Probe; Gush; Imperial Seal; Library of Alexandria; Lion's Eye Diamond; Lodestone Golem; Lotus Petal; Mana Crypt; Mana Vault; Memory Jar; Merchant Scroll; Mind's Desire; Monastery Mentor; Mox Emerald; Mox Jet; Mox Pearl; Mox Ruby; Mox Sapphire; Mystical Tutor; Necropotence; Ponder; Sol Ring; Strip Mine; Thorn of Amethyst; Time Vault; Time Walk; Timetwister; Tinker; Tolarian Academy; Treasure Cruise; Trinisphere; Vampiric Tutor; Wheel of Fortune; Windfall; Yawgmoth's Will + diff --git a/forge-gui/res/formats/blocks.txt b/forge-gui/res/formats/blocks.txt deleted file mode 100644 index 1412ff4cd9f..00000000000 --- a/forge-gui/res/formats/blocks.txt +++ /dev/null @@ -1,2 +0,0 @@ -[Kaladesh_Block] -Sets:KLD, AER \ No newline at end of file diff --git a/forge-gui/res/formats/coreformats.txt b/forge-gui/res/formats/coreformats.txt deleted file mode 100644 index b304eede31b..00000000000 --- a/forge-gui/res/formats/coreformats.txt +++ /dev/null @@ -1,21 +0,0 @@ -[Standard] -Sets:KLD, AER, AKH, W17, HOU, XLN, RIX -Banned: Attune with Aether; Rogue Refiner; Rampaging Ferocidon; Ramunap Ruins; Smuggler's Copter; Aetherworks Marvel; Felidar Guardian - -[Modern] -Sets:8ED, MRD, DST, 5DN, CHK, BOK, SOK, 9ED, RAV, GPT, DIS, CSP, TSP, TSB, PLC, FUT, 10E, LRW, EVE, SHM, MOR, ALA, CFX, ARB, M10, ZEN, WWK, ROE, M11, SOM, MBS, NPH, M12, ISD, DKA, AVR, M13, RTR, GTC, DGM, M14, THS, BNG, JOU, M15, KTK, FRF, DTK, MM2, ORI, BFZ, OGW, SOI, EMN, KLD, AER, AKH, W17, HOU, XLN, RIX -Banned:Ancient Den; Birthing Pod; Blazing Shoal; Chrome Mox; Cloudpost; Dark Depths; Deathrite Shaman; Dig Through Time; Dread Return; Eye of Ugin; Gitaxian Probe; Glimpse of Nature; Golgari Grave-Troll; Great Furnace; Green Sun's Zenith; Hypergenesis; Mental Misstep; Ponder; Preordain; Punishing Fire; Rite of Flame; Seat of the Synod; Second Sunrise; Seething Song; Sensei's Divining Top; Skullclamp; Splinter Twin; Stoneforge Mystic; Summer Bloom; Treasure Cruise; Tree of Tales; Umezawa's Jitte; Vault of Whispers - -[Vintage] -Banned:Adriana's Valor; Advantageous Proclamation; Assemble the Rank and Vile; Backup Plan; Brago's Favor; Double Stroke; Echoing Boon; Emissary's Ploy; Hired Heist; Hold the Perimeter; Hymn of the Wilds; Immediate Action; Incendiary Dissent; Iterative Analysis; Muzzio's Preparations; Natural Unity; Power Play; Secret Summoning; Secrets of Paradise; Sentinel Dispatch; Sovereign's Realm; Summoner's Bond; Unexpected Potential; Weight Advantage; Worldknit; Amulet of Quoz; Bronze Tablet; Contract from Below; Darkpact; Demonic Attorney; Jeweled Bird; Rebirth; Tempest Efreet; Timmerian Fiends; Chaos Orb; Falling Star; Shahrazad -Restricted:Ancestral Recall; Balance; Black Lotus; Brainstorm; Chalice of the Void; Channel; Demonic Consultation; Demonic Tutor; Dig Through Time; Fastbond; Flash; Gitaxian Probe; Gush; Imperial Seal; Library of Alexandria; Lion's Eye Diamond; Lodestone Golem; Lotus Petal; Mana Crypt; Mana Vault; Memory Jar; Merchant Scroll; Mind's Desire; Monastery Mentor; Mox Emerald; Mox Jet; Mox Pearl; Mox Ruby; Mox Sapphire; Mystical Tutor; Necropotence; Ponder; Sol Ring; Strip Mine; Thorn of Amethyst; Time Vault; Time Walk; Timetwister; Tinker; Tolarian Academy; Treasure Cruise; Trinisphere; Vampiric Tutor; Wheel of Fortune; Windfall; Yawgmoth's Will - -[Legacy] -Banned:Adriana's Valor; Advantageous Proclamation; Assemble the Rank and Vile; Backup Plan; Brago's Favor; Double Stroke; Echoing Boon; Emissary's Ploy; Hired Heist; Hold the Perimeter; Hymn of the Wilds; Immediate Action; Incendiary Dissent; Iterative Analysis; Muzzio's Preparations; Natural Unity; Power Play; Secret Summoning; Secrets of Paradise; Sentinel Dispatch; Sovereign's Realm; Summoner's Bond; Unexpected Potential; Weight Advantage; Worldknit; Amulet of Quoz; Bronze Tablet; Contract from Below; Darkpact; Demonic Attorney; Jeweled Bird; Rebirth; Tempest Efreet; Timmerian Fiends; Ancestral Recall; Balance; Bazaar of Baghdad; Black Lotus; Channel; Chaos Orb; Demonic Consultation; Demonic Tutor; Dig Through Time; Earthcraft; Falling Star; Fastbond; Flash; Frantic Search; Goblin Recruiter; Gush; Hermit Druid; Imperial Seal; Library of Alexandria; Mana Crypt; Mana Drain; Mana Vault; Memory Jar; Mental Misstep; Mind Twist; Mind's Desire; Mishra's Workshop; Mox Emerald; Mox Jet; Mox Pearl; Mox Ruby; Mox Sapphire; Mystical Tutor; Necropotence; Oath of Druids; Sensei's Divining Top; Shahrazad; Skullclamp; Sol Ring; Strip Mine; Survival of the Fittest; Time Vault; Time Walk; Timetwister; Tinker; Tolarian Academy; Treasure Cruise; Vampiric Tutor; Wheel of Fortune; Windfall; Yawgmoth's Bargain; Yawgmoth's Will - -[Commander] -Banned:Adriana's Valor; Advantageous Proclamation; Ashnod's Coupon; Assemble the Rank and Vile; Backup Plan; Brago's Favor; Double Cross; Double Deal; Double Dip; Double Play; Double Stroke; Double Take; Echoing Boon; Emissary's Ploy; Enter the Dungeon; Hired Heist; Hold the Perimeter; Hymn of the Wilds; Immediate Action; Incendiary Dissent; Iterative Analysis; Magical Hacker; Mox Lotus; Muzzio's Preparations; Natural Unity; Once More with Feeling; Power Play; R&D's Secret Lair; Richard Garfield, Ph.D.; Secret Summoning; Secrets of Paradise; Sentinel Dispatch; Sovereign's Realm; Staying Power; Summoner's Bond; Time Machine; Unexpected Potential; Weight Advantage; Worldknit; Amulet of Quoz; Bronze Tablet; Contract from Below; Darkpact; Demonic Attorney; Jeweled Bird; Rebirth; Tempest Efreet; Timmerian Fiends; Ancestral Recall; Balance; Biorhythm; Black Lotus; Braids, Cabal Minion; Chaos Orb; Coalition Victory; Channel; Emrakul, the Aeons Torn; Erayo, Soratami Ascendant; Falling Star; Fastbond; Gifts Ungiven; Griselbrand; Karakas; Leovold, Emissary of Trest; Library of Alexandria; Limited Resources; Mox Emerald; Mox Jet; Mox Pearl; Mox Ruby; Mox Sapphire; Painter's Servant; Panoptic Mirror; Primeval Titan; Prophet of Kruphix; Recurring Nightmare; Rofellos, Llanowar Emissary; Shahrazad; Staying Power; Sundering Titan; Sway of the Stars; Sylvan Primordial; Time Machine; Time Vault; Time Walk; Tinker; Tolarian Academy; Trade Secrets; Upheaval; Worldfire; Yawgmoth's Bargain - -[Extended] -Sets:SOM, MBS, NPH, M12, ISD, DKA, AVR, M13, RTR, GTC, DGM, M14, THS, BNG, JOU, M15 -Banned:Ponder; Mental Misstep diff --git a/forge-gui/res/formats/pauper.txt b/forge-gui/res/formats/pauper.txt index 0ee5be9e5b6..e5b10f4fb39 100644 --- a/forge-gui/res/formats/pauper.txt +++ b/forge-gui/res/formats/pauper.txt @@ -1,2 +1,5 @@ -[Pauper] +[format] +Name:Pauper +Order:108 +Core:true Rarities:L, C \ No newline at end of file diff --git a/forge-gui/res/formats/standard.txt b/forge-gui/res/formats/standard.txt new file mode 100644 index 00000000000..63c014ed574 --- /dev/null +++ b/forge-gui/res/formats/standard.txt @@ -0,0 +1,6 @@ +[format] +Name:Standard +Order:101 +Core:true +Sets:KLD, AER, AKH, W17, HOU, XLN, RIX +Banned: Attune with Aether; Rogue Refiner; Rampaging Ferocidon; Ramunap Ruins; Smuggler's Copter; Aetherworks Marvel; Felidar Guardian diff --git a/forge-gui/src/main/java/forge/model/FModel.java b/forge-gui/src/main/java/forge/model/FModel.java index ec477071f4e..e1c1ca0b53d 100644 --- a/forge-gui/src/main/java/forge/model/FModel.java +++ b/forge-gui/src/main/java/forge/model/FModel.java @@ -166,21 +166,7 @@ public final class FModel { ForgePreferences.DEV_MODE = preferences.getPrefBoolean(FPref.DEV_MODE_ENABLED); ForgePreferences.UPLOAD_DRAFT = ForgePreferences.NET_CONN; - formats = new GameFormat.Collection(new GameFormat.Reader( new File(ForgeConstants.FORMATS_DATA_DIR + "coreformats.txt"))); - final File[] files = new File(ForgeConstants.FORMATS_DATA_DIR).listFiles(); - for (final File file : files) { - if (!file.getName().equals("coreformats.txt")){ - GameFormat.Collection additionalformats = new GameFormat.Collection(new GameFormat.Reader(file)); - for (GameFormat format:additionalformats) { - formats.add(format); - } - } - } - //still support old user custom formats if file present - GameFormat.Collection customFormats = new GameFormat.Collection(new GameFormat.Reader(new File(ForgeConstants.USER_PREFS_DIR + "customformats.txt"))); - for (GameFormat format:customFormats){ - formats.add(format); - } + formats = new GameFormat.Collection(new GameFormat.Reader( new File(ForgeConstants.FORMATS_DATA_DIR))); magicDb.setStandardPredicate(formats.getStandard().getFilterRules()); magicDb.setModernPredicate(formats.getModern().getFilterRules()); diff --git a/forge-gui/src/main/java/forge/quest/data/GameFormatQuest.java b/forge-gui/src/main/java/forge/quest/data/GameFormatQuest.java index 73839f566a0..b67d056881c 100644 --- a/forge-gui/src/main/java/forge/quest/data/GameFormatQuest.java +++ b/forge-gui/src/main/java/forge/quest/data/GameFormatQuest.java @@ -63,7 +63,7 @@ public final class GameFormatQuest extends GameFormat { */ public GameFormatQuest(final GameFormat toCopy, boolean allowSetUnlocks) { super(toCopy.getName(), toCopy.getAllowedSetCodes(), toCopy.getBannedCardNames(), toCopy.getRestrictedCards(), - toCopy.getAllowedRarities(), toCopy.getIndex()); + toCopy.getAllowedRarities(), toCopy.getIndex(), false); allowUnlocks = allowSetUnlocks; }