xml.append("</UnitType>");
return xml.toString();
}
public UnitType initializeFromNode(Realm realm, Node node) {
UnitType unitType = new UnitType();
int idValue = Integer.parseInt(node.getAttributes().getNamedItem("id").getNodeValue());
String nameValue = node.getAttributes().getNamedItem("name").getNodeValue();
int explorationRadius = Integer.parseInt(node.getAttributes().getNamedItem("explorationRadius").getNodeValue());
int weightForContainerValue = Integer.parseInt(node.getAttributes().getNamedItem("weightForContainer").getNodeValue());
unitType.setId(idValue);
unitType.setName(nameValue);
unitType.setExplorationRadius(explorationRadius);
unitType.setWeightForContainer(weightForContainerValue);
for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
if (subNode.getNodeType() == Node.ELEMENT_NODE) {
if (subNode.getNodeName().equals("Properties")) {
for (Node abilityNode = subNode.getFirstChild(); abilityNode != null; abilityNode = abilityNode.getNextSibling()) {
if (abilityNode.getNodeType() == Node.ELEMENT_NODE) {
Property ability = PropertyFactory.createProperty(realm, abilityNode);
unitType.addAbility(ability);
}
}
}
}
}