for(Base base: game.getBaseManager().getBases()) {
// new player
Element baseElement = new Element("base");
basesElement.addContent(baseElement);
// attributes
Attribute id = new Attribute("id", String.valueOf(base.getId()));
Attribute x = new Attribute("x", String.valueOf(base.getPosition().x));
Attribute y = new Attribute("y", String.valueOf(base.getPosition().y));
if(base.getPlayer() != null) {
Attribute player = new Attribute("player", base.getPlayer().getName());
baseElement.setAttribute(player);
}
Attribute nbAgents = new Attribute("nbAgents", String.valueOf(base.getNbAgents()));
Attribute might = new Attribute("might", String.valueOf(base.getMight()));
baseElement.setAttribute(id);
baseElement.setAttribute(x);
baseElement.setAttribute(y);
baseElement.setAttribute(nbAgents);
baseElement.setAttribute(might);