Exemplo n.º 1
0
  public void parseXML(Node rootNode) {
    try {
      NumberFormat nf = WLPNumberFormat.getInstance();
      NamedNodeMap attrs = rootNode.getAttributes();
      if (attrs != null) {
        Node nameNode = attrs.getNamedItem(nameTag);
        if (nameNode != null) {
          name = nameNode.getTextContent().trim();
        }
        Node guidNode = attrs.getNamedItem(guidTag);
        if (guidNode != null) {
          guid = guidNode.getTextContent().trim();
        }
      }

      Node mergedNode = XmlHelper.getChildNode(rootNode, mergedTag);
      if (mergedNode != null) {
        merged = Boolean.parseBoolean(mergedNode.getTextContent().trim());
      }

      Node durationNode = XmlHelper.getChildNode(rootNode, durationTag);
      if (durationNode != null) {
        duration = nf.parse(durationNode.getTextContent().trim()).doubleValue();
      }

      Node activeDurationNode = XmlHelper.getChildNode(rootNode, activeDurationTag);
      if (activeDurationNode != null) {
        activeDuration = nf.parse(activeDurationNode.getTextContent().trim()).doubleValue();
      }

      Node numMobsNode = XmlHelper.getChildNode(rootNode, numMobsTag);
      if (numMobsNode != null) {
        numMobs = Integer.parseInt(numMobsNode.getTextContent().trim());
      }

      Node totalDamageNode = XmlHelper.getChildNode(rootNode, totalDamageTag);
      if (totalDamageNode != null) {
        totalDamage = Long.parseLong(totalDamageNode.getTextContent().trim());
      }

      Node victimNode = XmlHelper.getChildNode(rootNode, victimTag);
      if (victimNode != null) {
        Node victimFightparticipantNode =
            XmlHelper.getChildNode(victimNode, XMLFightParticipant.fightParticipantTag);
        if (victimFightparticipantNode != null) {
          xmlVictim = new XMLFightParticipant();
          xmlVictim.parseXML(victimFightparticipantNode);
        }
      }
      List<Node> fightParticipantNodes =
          XmlHelper.getChildNodes(rootNode, XMLFightParticipant.fightParticipantTag);
      fightParticipants = new ArrayList<XMLFightParticipant>();
      for (Node partNode : fightParticipantNodes) {
        if (partNode != null) {
          XMLFightParticipant xmlPart = new XMLFightParticipant();
          xmlPart.parseXML(partNode);
          fightParticipants.add(xmlPart);
        }
      }
    } catch (ParseException ex) {
      throw new NumberFormatException();
    }
  }
Exemplo n.º 2
0
  public void addFightInfo(Element e) {
    NumberFormat nf = WLPNumberFormat.getInstance();
    nf.setMaximumFractionDigits(2);
    Element mergedElement = doc.createElement(mergedTag);
    mergedElement.setTextContent("" + fight.isMerged());
    e.appendChild(mergedElement);

    Element durationElement = doc.createElement(durationTag);
    durationElement.setTextContent(nf.format(fight.getEndTime() - fight.getStartTime()));
    e.appendChild(durationElement);

    Element activeDurationElement = doc.createElement(activeDurationTag);
    activeDurationElement.setTextContent(nf.format(fight.getActiveDuration()));
    e.appendChild(activeDurationElement);

    Element numMobsElement = doc.createElement(numMobsTag);
    if (fight.isMerged()) {
      numMobsElement.setTextContent(nf.format(fight.getMergedSourceFights().size()));
      Element npcsElement = doc.createElement(npcsTag);
      e.appendChild(npcsElement);
      List<Fight> sourceFights = fight.getMergedSourceFights();
      for (Fight f : sourceFights) {
        Element npcElement = createNpcElement(f, nf);
        npcsElement.appendChild(npcElement);
      }
    } else {
      numMobsElement.setTextContent(nf.format(1));
      Element npcsElement = doc.createElement(npcsTag);
      e.appendChild(npcsElement);
      Element npcElement = createNpcElement(fight, nf);
      npcsElement.appendChild(npcElement);
    }
    e.appendChild(numMobsElement);

    Element totalDamageElement = doc.createElement(totalDamageTag);
    Element totalHealingElement = doc.createElement(totalHealingTag);
    long damage = 0;
    long healing = 0;
    for (FightParticipant p : fight.getParticipants()) {
      AmountAndCount a = p.totalDamage(Constants.SCHOOL_ALL, FightParticipant.TYPE_ALL_DAMAGE);
      damage += a.amount;
      a = p.totalHealing(Constants.SCHOOL_ALL, FightParticipant.TYPE_ALL_HEALING);
      healing += a.amount;
    }
    totalDamageElement.setTextContent(nf.format(damage));
    e.appendChild(totalDamageElement);
    totalHealingElement.setTextContent(nf.format(healing));
    e.appendChild(totalHealingElement);

    Element dispellInfoElement = doc.createElement(dispellInfoTag);
    DispellEvents de = new DispellEvents(fight.getEvents());
    int numNames = de.getNumNames();
    for (int k = 0; k < numNames; k++) {
      String auraName = de.getName(k);
      Element auraElement = doc.createElement(auraDispelledTag);
      auraElement.setAttribute(nameTag, auraName);
      List<SpellAuraDispelledEvent> events = de.getEvents(auraName);
      for (SpellAuraDispelledEvent ev : events) {
        Element eventElement = doc.createElement(dispEventTag);
        ev.addXmlAttributes(eventElement);
        //                eventElement.setAttribute(sourceTag, ev.sourceName);
        //                eventElement.setAttribute(sourceGuidTag, ev.sourceGUID);
        //                eventElement.setAttribute(skillTag, ev.getName());
        //                eventElement.setAttribute(targetTag, ev.destinationName);
        //                eventElement.setAttribute(destinationGuidTag, ev.destinationGUID);
        //                eventElement.setAttribute(timeTag, ev.getTimeStringExact());
        auraElement.appendChild(eventElement);
      }
      dispellInfoElement.appendChild(auraElement);
    }
    e.appendChild(dispellInfoElement);

    Element interruptInfoElement = doc.createElement(interruptInfoTag);
    InterruptEvents ie = new InterruptEvents(fight.getEvents());
    numNames = ie.getNumNames();
    for (int k = 0; k < numNames; k++) {
      String spellName = ie.getName(k);
      Element spellElement = doc.createElement(spellInterruptedTag);
      spellElement.setAttribute(nameTag, spellName);
      List<SpellInterruptEvent> events = ie.getEvents(spellName);
      for (SpellInterruptEvent ev : events) {
        Element eventElement = doc.createElement(intEventTag);
        ev.addXmlAttributes(eventElement);
        //                eventElement.setAttribute(sourceTag, ev.sourceName);
        //                eventElement.setAttribute(skillTag, ev.getName());
        //                eventElement.setAttribute(targetTag, ev.destinationName);
        //                eventElement.setAttribute(timeTag, ev.getTimeStringExact());
        spellElement.appendChild(eventElement);
      }
      interruptInfoElement.appendChild(spellElement);
    }
    e.appendChild(interruptInfoElement);
  }