xml.append("</relations>\n");
return xml.toString();
}
public Diplomacy initializeFromNode(Realm realm, Node node) {
Diplomacy diplomacy = new Diplomacy();
Node tileTypesNode = XMLConverterUtility.findNode(node, "relations");
for (Node subNode = tileTypesNode.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
if (subNode.getNodeType() == Node.ELEMENT_NODE) {
int player1Id = Integer.parseInt(XMLConverterUtility.findNode(subNode, "player1").getFirstChild().getNodeValue());
int player2Id = Integer.parseInt(XMLConverterUtility.findNode(subNode, "player2").getFirstChild().getNodeValue());
int status = Integer.parseInt(XMLConverterUtility.findNode(subNode, "status").getFirstChild().getNodeValue());
Player player1 = realm.getPlayerManager().getPlayer(player1Id);
Player player2 = realm.getPlayerManager().getPlayer(player2Id);
diplomacy.addPlayerRelation(player1, player2, status);
}
}
return diplomacy;
}