Files now load from mb.data/wpak/<archive>/<file>, matching MBDATA's data/wpak layout and the client's Config/Config.wpak naming, so more archives can sit beside Config/ later. All nine current files are in wpak/Config/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.4 KiB
Java
60 lines
2.4 KiB
Java
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
|
// Magicbane Emulator Project © 2013 - 2026
|
|
// https://www.magicbane.com
|
|
|
|
package engine.parsers.wpak;
|
|
|
|
import engine.mbEnums;
|
|
import engine.parsers.objects.wpak.PowActionCostTemplate;
|
|
import org.pmw.tinylog.Logger;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
|
|
// Loads PowActionCostInfo.cfg (client loader EffectCostMap_LoadPowActionCostInfo 0x6E00C0).
|
|
|
|
public class PowActionCostParser {
|
|
|
|
private static final String fileName = "Config/PowActionCostInfo.cfg";
|
|
|
|
public static HashMap<String, PowActionCostTemplate> parsePowActionCostFile() {
|
|
|
|
HashMap<String, PowActionCostTemplate> costs = new HashMap<>();
|
|
ArrayList<WpakLine> lines;
|
|
PowActionCostTemplate cost;
|
|
int failedCount = 0;
|
|
|
|
try {
|
|
lines = WpakFileReader.readLines(fileName);
|
|
} catch (Exception e) {
|
|
Logger.error(fileName + ": " + e.getMessage());
|
|
return null;
|
|
}
|
|
|
|
for (WpakLine line : lines) {
|
|
try {
|
|
// A repeated id adds its pairs to the existing entry, as the client does
|
|
cost = costs.computeIfAbsent(line.token(0), id -> new PowActionCostTemplate());
|
|
cost.id = line.token(0);
|
|
|
|
for (int i = 1; i < line.size(); i += 2)
|
|
cost.costs.put(line.enumToken(mbEnums.ResourceType.class, i), line.intToken(i + 1));
|
|
} catch (WpakFormatException e) {
|
|
Logger.error(e.getMessage());
|
|
failedCount++;
|
|
}
|
|
}
|
|
|
|
Logger.info("Loaded " + costs.size() + " power action resource costs from " + lines.size() + " lines");
|
|
|
|
if (failedCount > 0)
|
|
return null;
|
|
|
|
return costs;
|
|
}
|
|
}
|