List of usage examples for org.dom4j Element add
void add(Namespace namespace);
Namespace
to this element. From source file:de.ailis.wlandsuite.game.blocks.GameMap.java
License:Open Source License
/** * @see de.ailis.wlandsuite.game.blocks.GameBlock#toXml() *//*from w ww . j a va2 s.c o m*/ @Override public Element toXml() { Element element; // Create the root element element = XmlUtils.createElement("map"); element.addAttribute("mapSize", Integer.toString(this.mapSize)); if (this.msqSize != 0) { element.addAttribute("msqSize", Integer.toString(this.msqSize)); } if (this.tilemapOffset != 0) { element.addAttribute("tilemapOffset", Integer.toString(this.tilemapOffset)); } // Add the action map element.add(this.actionClassMap.toXml()); // Add the action map element.add(this.actionMap.toXml(this.actionClassMap)); // Add the map info element.add(this.info.toXml()); // Add the battle strings element.add(this.battleStrings.toXml()); // Add the actions for (int i = 1; i < 16; i++) { Actions actions; actions = this.actions.get(i); if (actions != null && actions.countActions() > 0) { element.add(actions.toXml(i)); } } // Add the NPCs element.add(this.npcs.toXml()); // Add the monsters element.add(this.monsters.toXml()); // Add the strings element.add(this.strings.toXml()); // Add the tiles map element.add(this.tileMap.toXml(this.info.getBackgroundTile())); // Return the XMl element return element; }
From source file:de.ailis.wlandsuite.game.blocks.Savegame.java
License:Open Source License
/** * @see de.ailis.wlandsuite.game.blocks.GameBlock#toXml() *///from w ww .j a v a 2s . c o m @Override public Element toXml() { Element element, subElement; // Create the root element element = XmlUtils.createElement("savegame"); element.addAttribute("time", String.format("%02d:%02d", new Object[] { this.hour, this.minute })); element.addAttribute("serial", Long.toString(this.serial)); // Add the parties element element.add(this.parties.toXml()); // Add the unknown block at position 0x38 element.add(this.unknown38.toXml("unknown38")); // Add the unknown block at position 0x7A element.add(this.unknown7A.toXml("unknown7A")); // Add the unknown block at position 0x82 element.add(this.unknown82.toXml("unknown82")); // Add the unknown block at position 0x85 element.add(this.unknown85.toXml("unknown85")); // Add the unknown block at position 0xF9 element.add(this.unknownF9.toXml("unknownF9")); // Write the characters subElement = XmlUtils.createElement("characters"); int id = 1; for (final Char characters : this.characters) { subElement.add(characters.toXml(id)); id++; } element.add(subElement); // Return the XMl element return element; }
From source file:de.ailis.wlandsuite.game.blocks.ShopItemList.java
License:Open Source License
/** * @see de.ailis.wlandsuite.game.blocks.GameBlock#toXml() *//*from ww w . j a va2s . co m*/ @Override public Element toXml() { Element element; int id; // Create the root element element = XmlUtils.createElement("shopItems"); id = 0; for (final ShopItem item : this.items) { element.add(item.toXml(id)); id++; } // Return the XMl element return element; }
From source file:de.ailis.wlandsuite.game.parts.ActionClassMap.java
License:Open Source License
/** * Returns the action classes map in XML format. * * @return The action classes map in XML *//*from ww w .j av a2 s . c om*/ public Element toXml() { Element element; StringWriter text; PrintWriter writer; int mapSize; // Determine the map size mapSize = this.actionClasses.length; // Create the root XML element element = XmlUtils.createElement("actionClassMap"); // Write the actionClasses content text = new StringWriter(); writer = new PrintWriter(text); writer.println(); for (int y = 0; y < mapSize; y++) { // Write indentation writer.print(" "); for (int x = 0; x < mapSize; x++) { int b; b = this.actionClasses[y][x]; if (b == 0) { // For action class 0 it's ok to write a dot instead of 0. writer.print('.'); } else { // For all other action classes write the hex character writer.print(Integer.toHexString(b)); } } writer.println(); } writer.print(" "); element.add(DocumentHelper.createText(text.toString())); // Return the XML element return element; }
From source file:de.ailis.wlandsuite.game.parts.ActionMap.java
License:Open Source License
/** * Returns the action map in XML format. * * @param actionClassMap/*from ww w .ja v a 2 s .c o m*/ * The action class map * @return The action map in XML */ public Element toXml(final ActionClassMap actionClassMap) { Element element; StringWriter text; PrintWriter writer; int mapSize; // Determine the map size mapSize = this.actions.length; // Create the root XML element element = XmlUtils.createElement("actionMap"); // Write the actions content text = new StringWriter(); writer = new PrintWriter(text); writer.println(); for (int y = 0; y < mapSize; y++) { writer.print(" "); for (int x = 0; x < mapSize; x++) { int b; if (x > 0) { writer.print(" "); } b = this.actions[y][x]; if (b == 0 && (actionClassMap.getActionClass(x, y) == 0)) { writer.print(".."); } else { writer.format("%02x", new Object[] { b }); } } writer.println(); } writer.print(" "); element.add(DocumentHelper.createText(text.toString())); // Return the XML element return element; }
From source file:de.ailis.wlandsuite.game.parts.Actions.java
License:Open Source License
/** * Returns the actions as XML.//from w ww. ja v a2 s. co m * * @param actionClass * The action class (1-15) * @return The actions as XML */ public Element toXml(final int actionClass) { Element element; int id; element = XmlUtils.createElement("actions"); element.addAttribute("actionClass", StringUtils.toHex(actionClass)); id = 0; for (final Action action : this.actions) { if (action != null) { element.add(action.toXml(id)); } id++; } return element; }
From source file:de.ailis.wlandsuite.game.parts.AlterationAction.java
License:Open Source License
/** * @see de.ailis.wlandsuite.game.parts.Action#toXml(int) */// www.j ava 2s.co m @Override public Element toXml(final int id) { Element element; element = XmlUtils.createElement("alteration"); element.addAttribute("id", StringUtils.toHex(id)); if (this.message != 0) { element.addAttribute("message", Integer.toString(this.message)); } if (this.newActionClass != 255) { element.addAttribute("newActionClass", StringUtils.toHex(this.newActionClass)); } if (this.newAction != 255) { element.addAttribute("newAction", StringUtils.toHex(this.newAction)); } for (final Alter alteration : this.alterations) { element.add(alteration.toXml()); } return element; }
From source file:de.ailis.wlandsuite.game.parts.Char.java
License:Open Source License
/** * Returns the character as XML./* ww w . ja v a 2s. co m*/ * * @param id * The character id * @return The character as XML */ public Element toXml(final int id) { Element element; element = XmlUtils.createElement("character"); element.addAttribute("id", Integer.toString(id)); element.addAttribute("name", StringUtils.escape(this.name, "ASCII")); element.addAttribute("strength", Integer.toString(this.strength)); element.addAttribute("iq", Integer.toString(this.iq)); element.addAttribute("luck", Integer.toString(this.luck)); element.addAttribute("speed", Integer.toString(this.speed)); element.addAttribute("agility", Integer.toString(this.agility)); element.addAttribute("dexterity", Integer.toString(this.dexterity)); element.addAttribute("charisma", Integer.toString(this.charisma)); element.addAttribute("money", Integer.toString(this.money)); element.addAttribute("gender", this.gender == 0 ? "male" : "female"); element.addAttribute("nationality", getNationality(this.nationality)); element.addAttribute("ac", Integer.toString(this.ac)); element.addAttribute("maxCon", Integer.toString(this.maxCon)); element.addAttribute("con", Integer.toString(this.con)); if (this.weapon != 0) { element.addAttribute("weapon", Integer.toString(this.weapon)); } if (this.skillPoints != 0) { element.addAttribute("skillPoints", Integer.toString(this.skillPoints)); } if (this.experience != 0) { element.addAttribute("experience", Integer.toString(this.experience)); } if (this.level != 1) { element.addAttribute("level", Integer.toString(this.level)); } if (this.armor != 0) { element.addAttribute("armor", Integer.toString(this.armor)); } if (this.lastCon != 0) { element.addAttribute("lastCon", Integer.toString(this.lastCon)); } if (this.afflictions != 0) { element.addAttribute("afflictions", Integer.toString(this.afflictions)); } if (this.npc) { element.addAttribute("npc", "true"); } if (this.unknown2A != 0) { element.addAttribute("unknown2A", StringUtils.toHex(this.unknown2A)); } if (this.itemRefuse != 0) { element.addAttribute("itemRefuse", Integer.toString(this.itemRefuse)); } if (this.skillRefuse != 0) { element.addAttribute("skillRefuse", Integer.toString(this.skillRefuse)); } if (this.attribRefuse != 0) { element.addAttribute("attribRefuse", Integer.toString(this.attribRefuse)); } if (this.tradeRefuse != 0) { element.addAttribute("tradeRefuse", Integer.toString(this.tradeRefuse)); } if (this.unknown2F != 0) { element.addAttribute("unknown2F", StringUtils.toHex(this.unknown2F)); } if (this.joinString != 0) { element.addAttribute("joinString", Integer.toString(this.joinString)); } if (this.willingness != 0) { element.addAttribute("willingness", Integer.toString(this.willingness)); } if (!this.rank.equals("Private")) { element.addAttribute("rank", StringUtils.escape(this.rank, "ASCII")); } // Add the skills element.add(this.skills.toXml()); // Add the items element.add(this.items.toXml()); return element; }
From source file:de.ailis.wlandsuite.game.parts.CheckAction.java
License:Open Source License
/** * @see de.ailis.wlandsuite.game.parts.Action#toXml(int) *//*from w ww . j a v a2 s .c o m*/ @Override public Element toXml(final int id) { Element element; element = XmlUtils.createElement("check"); element.addAttribute("id", StringUtils.toHex(id)); if (this.passable) element.addAttribute("passable", "true"); if (this.autoCheck) element.addAttribute("autoCheck", "true"); if (this.party) element.addAttribute("party", "true"); if (this.damageAll) element.addAttribute("damageAll", "true"); if (this.passAll) element.addAttribute("passAll", "true"); if (this.unknown1) element.addAttribute("unknown1", "true"); if (this.bypassArmor) element.addAttribute("bypassArmor", "true"); if (this.startMessage != 0) { element.addAttribute("startMessage", Integer.toString(this.startMessage)); } if (this.passMessage != 0) { element.addAttribute("passMessage", Integer.toString(this.passMessage)); } if (this.failMessage != 0) { element.addAttribute("failMessage", Integer.toString(this.failMessage)); } if (this.passNewActionClass != 255) { element.addAttribute("passNewActionClass", StringUtils.toHex(this.passNewActionClass)); } if (this.passNewAction != 255) { element.addAttribute("passNewAction", StringUtils.toHex(this.passNewAction)); } if (this.failNewActionClass != 255) { element.addAttribute("failNewActionClass", StringUtils.toHex(this.failNewActionClass)); } if (this.failNewAction != 255) { element.addAttribute("failNewAction", StringUtils.toHex(this.failNewAction)); } if (this.fixedModifier) element.addAttribute("fixedModifier", "true"); if (this.modifierTarget != 0x1d) { element.addAttribute("modifierTarget", StringUtils.toHex(this.modifierTarget)); } if (this.modifier != 0) { element.addAttribute("modifier", Integer.toString(this.modifier)); } for (final Check check : this.checks) { element.add(check.toXml()); } return element; }
From source file:de.ailis.wlandsuite.game.parts.DialogueAction.java
License:Open Source License
/** * @see de.ailis.wlandsuite.game.parts.Action#toXml(int) */// w w w .jav a 2 s . c o m @Override public Element toXml(final int id) { Element element; element = XmlUtils.createElement("dialogue"); element.addAttribute("id", StringUtils.toHex(id)); if (this.menu) { element.addAttribute("menu", "true"); } if (this.message != 0) { element.addAttribute("message", Integer.toString(this.message)); } if (this.cancelNewActionClass != 255) { element.addAttribute("cancelNewActionClass", StringUtils.toHex(this.cancelNewActionClass)); } if (this.cancelNewAction != 255) { element.addAttribute("cancelNewAction", StringUtils.toHex(this.cancelNewAction)); } if (this.otherNewActionClass != 255) { element.addAttribute("otherNewActionClass", StringUtils.toHex(this.otherNewActionClass)); } if (this.otherNewAction != 255) { element.addAttribute("otherNewAction", StringUtils.toHex(this.otherNewAction)); } for (final Answer answer : this.answers) { element.add(answer.toXml()); } return element; }