Example #1
0
	private void createExpansionElements(Game game) {
		for(Expansion exp : game.getExpansions()) {
			Element el = doc.createElement("expansion");
			el.setAttribute("name", exp.name());
			root.appendChild(el);
			ExpandedGame expandedBy = game.getExpandedGameFor(exp);
			if (expandedBy != null) {
				expandedBy.saveToSnapshot(doc, el);
			}
		}
	}
Example #2
0
	public void loadExpansionData(Game game) {
		NodeList nl = root.getElementsByTagName("expansion");
		for(int i = 0; i < nl.getLength(); i++) {
			Element el = (Element) nl.item(i);
			Expansion exp = Expansion.valueOf(el.getAttribute("name"));
			ExpandedGame eg = game.getExpandedGameFor(exp);
			if (eg != null) {
				try {
					eg.loadFromSnapshot(doc, el);
				} catch (Exception e) {
					logger.error("Incompatible or corrupted snapshot. Problem with stored expansion: " + exp.name(), e);
					game.getUserInterface().showWarning(_("Load error"), _("Saved game is incompatible or file is corrupted. Game couldn't work properly."));
				}
			}
		}
	}
Example #3
0
	public Set<Expansion> getExpansions() {
		Set<Expansion> result = Sets.newHashSet();
		NodeList nl = root.getElementsByTagName("expansion");
		for(int i = 0; i < nl.getLength(); i++) {
			Element el = (Element) nl.item(i);
			Expansion exp = Expansion.valueOf(el.getAttribute("name"));
			result.add(exp);
		}
		return result;
	}