Exemple #1
0
  protected void attachFunc(Node n, Object template, String functionName, Condition attachCond) {
    Stats stat = Stats.valueOfXml(n.getAttributes().getNamedItem("stat").getNodeValue());
    int order = -1;
    final Node orderNode = n.getAttributes().getNamedItem("order");
    if (orderNode != null) {
      order = Integer.parseInt(orderNode.getNodeValue());
    }

    String valueString = n.getAttributes().getNamedItem("val").getNodeValue();
    double value;
    if (valueString.charAt(0) == '#') {
      value = Double.parseDouble(getTableValue(valueString));
    } else {
      value = Double.parseDouble(valueString);
    }

    final Condition applayCond = parseCondition(n.getFirstChild(), template);
    final FuncTemplate ft =
        new FuncTemplate(attachCond, applayCond, functionName, order, stat, value);
    if (template instanceof L2Item) {
      ((L2Item) template).attach(ft);
    } else if (template instanceof AbstractEffect) {
      ((AbstractEffect) template).attach(ft);
    } else {
      throw new RuntimeException("Attaching stat to a non-effect template!!!");
    }
  }