return null;
}
@SuppressWarnings("unchecked")
private static BuildingLevelData buildLevelData(Element root) {
BuildingLevelData levelData = new BuildingLevelData();
// Production
Element production = root.getChild("production");
levelData.setProduction(buildResourceMap(production));
// Consumption
Element consumption = root.getChild("consumption");
levelData.setConsumption(buildResourceMap(consumption));
// Store
Element store = root.getChild("store");
levelData.setStoreCapacity(buildResourceMap(store));
// Upgrade
Element upgrade = root.getChild("upgrade");
levelData.setUpgradeCost(buildResourceMap(upgrade));
// Technologies needed to upgrade
Element techs = root.getChild("technologies");
if (techs == null) {
levelData.setTechnologiesNeeded(null);
} else {
List<String> technologies = new ArrayList<String>();
List<Element> children = techs.getChildren("technology");
for (Element elem : children) {
technologies.add(elem.getText());
}
levelData.setTechnologiesNeeded(technologies);
}
// Special actions
Element actions = root.getChild("special");
if (actions == null) {
levelData.setSpecialActions(null);
} else {
List<String> actionList = new ArrayList<String>();
List<Element> children = actions.getChildren("action");
for (Element elem : children) {
// Create the special action
String name = elem.getChildText("name");
int duration = Integer.valueOf(elem.getChildText("duration"))
.intValue();
Map<Resource, BigDecimal> costMap = buildResourceMap(elem
.getChild("cost"));
String gfxKey = elem.getChildText("gfx");
String i18nKey = elem.getChildText("i18n");
SpecialActionManager.create(name, duration, costMap, gfxKey,
i18nKey);
actionList.add(name);
}
levelData.setSpecialActions(actionList);
}
return levelData;
}