/**
   * Parses an XML node for the data necessary to create a Warrior object <warrior name=""
   * status=""> <affiliation faction="" rank="" /> <skills gunnery="" piloting="" mod="" />
   * <quirks></quirks> <notes></notes> <enhancements> <enhancement></enhancement> </enhancements>
   * </warrior>
   *
   * @param n XML Node to parse
   * @throws java.lang.Exception
   */
  public Warrior(Node n) throws Exception {
    NamedNodeMap map = n.getAttributes();
    Name = FileCommon.DecodeFluff(map.getNamedItem("name").getTextContent().trim());
    Status = map.getNamedItem("status").getTextContent().trim();

    for (int i = 0; i < n.getChildNodes().getLength(); i++) {
      String nodeName = n.getChildNodes().item(i).getNodeName();

      if (nodeName.equals("affiliation")) {
        map = n.getChildNodes().item(i).getAttributes();
        Faction = map.getNamedItem("faction").getTextContent().trim();
        Rank = map.getNamedItem("rank").getTextContent().trim();
      }

      if (nodeName.equals("skills")) {
        map = n.getChildNodes().item(i).getAttributes();
        Gunnery = Integer.parseInt(map.getNamedItem("gunnery").getTextContent().trim());
        Piloting = Integer.parseInt(map.getNamedItem("piloting").getTextContent().trim());
        ManeiDomini = Double.parseDouble(map.getNamedItem("mod").getTextContent().trim());
      }

      if (nodeName.equals("quirks")) {
        Quirks = n.getChildNodes().item(i).getTextContent().trim();
      }
      if (nodeName.equals("notes")) {
        Notes = n.getChildNodes().item(i).getTextContent().trim();
      }
      if (nodeName.equals("enhancements")) {
        Node e = n.getChildNodes().item(i);
        Advantages a = new Advantages();
        for (int j = 0; j < e.getChildNodes().getLength(); j++) {
          if (e.getChildNodes().item(j).getNodeName().equals("enhancement")) {
            Enhancement adv =
                a.find(
                    e.getChildNodes()
                        .item(j)
                        .getAttributes()
                        .getNamedItem("code")
                        .getTextContent());
            if (adv != null) Enhancements.add(adv);
          }
        }
      }
    }
  }
 /**
  * Writes the xml format expected by Warrior into the stream given <warrior name="" status="">
  * <affiliation faction="" rank="" /> <skills gunnery="" piloting="" mod="" /> <quirks></quirks>
  * <notes></notes> <enhancements> <enhancement></enhancement> </enhancements> </warrior>
  *
  * @param file The filestream to write into
  * @throws java.io.IOException
  */
 public void SerializeXML(BufferedWriter file) throws IOException {
   file.write(
       CommonTools.Tabs(5)
           + "<warrior name=\""
           + FileCommon.EncodeFluff(this.Name.trim())
           + "\" status=\""
           + this.Status.trim()
           + "\">");
   file.newLine();
   file.write(
       CommonTools.Tabs(6)
           + "<affiliation faction=\""
           + this.Faction.trim()
           + "\" rank=\""
           + this.getRank().trim()
           + "\" />");
   file.newLine();
   file.write(
       CommonTools.Tabs(6)
           + "<skills gunnery=\""
           + this.Gunnery
           + "\" piloting=\""
           + this.Piloting
           + "\" mod=\""
           + this.getManeiDomini()
           + "\" />");
   file.newLine();
   file.write(CommonTools.Tabs(6) + "<quirks><![CDATA[" + this.Quirks.trim() + "]]></quirks>");
   file.newLine();
   file.write(CommonTools.Tabs(6) + "<notes><![CDATA[" + this.Notes + "]]></notes>");
   file.newLine();
   if (Enhancements.size() > 0) {
     file.write(CommonTools.Tabs(6) + "<enhancements>");
     file.newLine();
     for (Enhancement e : Enhancements) {
       file.write(CommonTools.Tabs(7) + e.SerializeXML());
       file.newLine();
     }
     file.write(CommonTools.Tabs(6) + "</enhancements>");
     file.newLine();
   }
   file.write(CommonTools.Tabs(5) + "</warrior>");
   file.newLine();
 }