mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Add support for "upcoming" folder in Card Workshop, and better filename calculation.
This commit is contained in:
@@ -68,14 +68,18 @@ public final class CardScriptInfo {
|
|||||||
public static CardScriptInfo getScriptFor(final String name) {
|
public static CardScriptInfo getScriptFor(final String name) {
|
||||||
CardScriptInfo script = allScripts.get(name);
|
CardScriptInfo script = allScripts.get(name);
|
||||||
if (script == null) { //attempt to load script if not previously loaded
|
if (script == null) { //attempt to load script if not previously loaded
|
||||||
final String filename = name.toLowerCase().replace(' ', '_').replace('-', '_').replace("'", "").replace(",", "") + ".txt";
|
final String filename = name.toLowerCase().replaceAll("[^-a-z0-9\\s]","").replaceAll("[-\\s]","_") + ".txt";
|
||||||
final File file = new File(ForgeConstants.CARD_DATA_DIR + filename.charAt(0) + File.separator + filename);
|
String[] folders = { String.valueOf(filename.charAt(0)), "upcoming"};
|
||||||
if (file.exists()) {
|
|
||||||
script = new CardScriptInfo(FileUtil.readFileToString(file), file);
|
for(String folder : folders){
|
||||||
allScripts.put(name, script);
|
final File file = new File(ForgeConstants.CARD_DATA_DIR + filename.charAt(0) + File.separator + filename);
|
||||||
|
if (file.exists()) {
|
||||||
|
script = new CardScriptInfo(FileUtil.readFileToString(file), file);
|
||||||
|
allScripts.put(name, script);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user