Node queueItemTypeNode = XMLConverterUtility.findNode(queueItemNode, "type");
String queueItemType = queueItemTypeNode.getFirstChild().getNodeValue();
Node queueItemIdNode = XMLConverterUtility.findNode(queueItemNode, "id");
int id = Integer.parseInt(queueItemIdNode.getFirstChild().getNodeValue());
if (queueItemType.equals("SETTLEMENT_IMPROVEMENT")) {
SettlementImprovementType cityImprovementType = realm.getSettlementImprovementManager().getImprovement(id);
settlement.addToProductionQueue(cityImprovementType);
} else if (queueItemType.equals("UNIT")) {
UnitType unitType = realm.getUnitTypeManager().getUnitType(id);
settlement.addToProductionQueue(unitType);
}
}
}
} else if (subNode.getNodeName().equals("contiuousProduction")) {
if (subNode.getFirstChild() != null) {
Boolean contiuousProductionValue = new Boolean(subNode.getFirstChild().getNodeValue());
settlement.setContiuousProduction(contiuousProductionValue);
}
} else if (subNode.getNodeName().equals("improvements")) {
settlement.clearImprovements();
for (Node improvementNode = subNode.getFirstChild(); improvementNode != null; improvementNode = improvementNode.getNextSibling()) {
if (improvementNode.getNodeType() == Node.ELEMENT_NODE) {
Node improvementTypeIdNode = XMLConverterUtility.findNode(improvementNode, "type");
int improvementId = Integer.parseInt(improvementTypeIdNode.getFirstChild().getNodeValue());
Node improvementEnabledNode = XMLConverterUtility.findNode(improvementNode, "enabled");
boolean enabled = Boolean.valueOf(improvementEnabledNode.getFirstChild().getNodeValue());
Node workersNode = XMLConverterUtility.findNode(improvementNode, "workers");
int workers = 0;
if (workersNode != null) {
workers = Integer.parseInt(workersNode.getFirstChild().getNodeValue());
}
SettlementImprovementType improvementType = realm.getSettlementImprovementManager().getImprovement(improvementId);
SettlementImprovement improvement = new SettlementImprovement();
improvement.setType(improvementType);
improvement.setEnabled(enabled);
improvement.setNumberOfWorkers(workers);
settlement.addImprovement(improvement);