String name = tileTypeNode.getAttributes().getNamedItem("name").getNodeValue();
int movementCost = Integer.parseInt(tileTypeNode.getAttributes().getNamedItem("movementCost").getNodeValue());
int probability = Integer.parseInt(tileTypeNode.getAttributes().getNamedItem("probability").getNodeValue());
int defencePercentage = Integer.parseInt(tileTypeNode.getAttributes().getNamedItem("defencePercentage").getNodeValue());
int id = Integer.parseInt(tileTypeNode.getAttributes().getNamedItem("id").getNodeValue());
TileType tileType = new TileType();
tileType.setName(name);
tileType.setMovementCost(movementCost);
tileType.setProbability(probability);
tileType.setDefencePercentage(defencePercentage);
tileType.setId(id);
for (Node subNode = tileTypeNode.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
if (subNode.getNodeType() == Node.ELEMENT_NODE) {
String resourceName = subNode.getNodeName();
int quantity = Integer.parseInt(subNode.getFirstChild().getNodeValue().trim());
Resource resource = realm.getResourceManager().getResource(resourceName);
tileType.addProduction(resource, quantity);
}
}
tileTypeManager.addTileType(tileType);
}
}