Files
lakebane/src/engine/ConfigParsing/EffectsParser.java
T

50 lines
2.1 KiB
Java
Raw Normal View History

2024-07-23 20:47:39 -05:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2024
// www.magicbane.com
package engine.ConfigParsing;
2024-07-24 12:56:24 -04:00
2024-08-06 16:56:41 -04:00
import engine.ConfigParsing.EffectEntry.EffectEntry;
2024-07-23 20:47:39 -05:00
import engine.gameManager.ConfigManager;
2024-07-23 21:15:37 -05:00
2024-07-23 20:47:39 -05:00
import java.io.IOException;
2024-07-24 12:56:24 -04:00
import java.nio.file.Files;
import java.nio.file.Paths;
2024-07-23 20:47:39 -05:00
import java.util.ArrayList;
2024-07-23 21:07:29 -05:00
import java.util.HashMap;
2024-07-23 20:47:39 -05:00
import java.util.List;
2024-08-06 16:52:06 -04:00
import java.util.regex.Matcher;
import java.util.regex.Pattern;
2024-07-23 20:47:39 -05:00
public class EffectsParser {
2024-07-24 12:56:24 -04:00
2024-07-23 21:02:41 -05:00
public static String EffectsPath = ConfigManager.DEFAULT_DATA_DIR + "wpak/Effects.cfg";
2024-08-06 16:56:41 -04:00
public static HashMap<String, EffectEntry> effect_data = new HashMap<>();
2024-08-06 16:52:06 -04:00
private static final Pattern EFFECT_REGEX = Pattern.compile("<EFFECTBEGIN>(.+?)</EFFECTEND>", Pattern.DOTALL);
private static final Pattern SOURCE_REGEX = Pattern.compile("<SOURCEBEGIN>(.+?)</SOURCEEND>", Pattern.DOTALL);
private static final Pattern MODS_REGEX = Pattern.compile("<MODSBEGIN>(.+?)</MODSEND>", Pattern.DOTALL);
2024-07-24 12:56:24 -04:00
2024-07-23 20:47:39 -05:00
public static void init() throws IOException {
2024-07-24 12:56:24 -04:00
2024-08-06 16:52:06 -04:00
byte[] fileData = Files.readAllBytes(Paths.get(EffectsPath));
String fileContents = new String(fileData);
2024-07-24 12:56:24 -04:00
2024-08-06 16:52:06 -04:00
final List<String> effectEntries = new ArrayList<>();
final Matcher matcher = EFFECT_REGEX.matcher(fileContents);
2024-07-24 12:56:24 -04:00
2024-08-06 16:52:06 -04:00
while (matcher.find()) {
effectEntries.add(matcher.group(1));
2024-07-23 20:47:39 -05:00
}
2024-07-24 12:56:24 -04:00
2024-07-23 20:47:39 -05:00
}
2024-08-06 16:56:41 -04:00
private static void parseEffectEntry(String effectEntry) {
}
2024-08-06 16:52:06 -04:00
}