xml.append("</TileImprovement>");
return xml.toString();
}
public TileImprovementType initializeFromNode(Realm realm, Node node) {
TileImprovementTypeImpl tileImprovementType = new TileImprovementTypeImpl();
int id = Integer.parseInt(XMLConverterUtility.findNode(node, "id").getFirstChild().getNodeValue());
String name = XMLConverterUtility.findNode(node, "name").getFirstChild().getNodeValue();
int productionCost = Integer.parseInt(XMLConverterUtility.findNode(node, "productionCost").getFirstChild().getNodeValue());
int upkeepCost = Integer.parseInt(XMLConverterUtility.findNode(node, "upkeepCost").getFirstChild().getNodeValue());
tileImprovementType.setId(id);
tileImprovementType.setName(name);
tileImprovementType.setProductionCost(productionCost);
tileImprovementType.setUpkeepCost(upkeepCost);
Node tileTypesNode = XMLConverterUtility.findNode(node, "tileTypes");
for (Node tileTypeNode = tileTypesNode.getFirstChild(); tileTypeNode != null; tileTypeNode = tileTypeNode.getNextSibling()) {
if (tileTypeNode.getNodeType() == Node.ELEMENT_NODE) {
int tileTypeId = Integer.parseInt(tileTypeNode.getFirstChild().getNodeValue());
TileType tileType = realm.getTileTypeManager().getTileType(tileTypeId);
tileImprovementType.addTileType(tileType);
}
}
Node propertiesNode = XMLConverterUtility.findNode(node, "properties");
for (Node propertyNode = propertiesNode.getFirstChild(); propertyNode != null; propertyNode = propertyNode.getNextSibling()) {
if (propertyNode.getNodeType() == Node.ELEMENT_NODE) {
Property property = PropertyFactory.createProperty(realm, propertyNode);
tileImprovementType.addProperty(property);
}
}
return tileImprovementType;
}