Esempio n. 1
0
  public AppearanceStone(StatsSet set) {
    _id = set.getInt("id");
    _visualId = set.getInt("visualId", 0);
    _cost = set.getInt("cost", 0);
    _lifeTime = set.getDuration("lifeTime", Duration.ofSeconds(0)).toMillis();
    _type = set.getEnum("type", AppearanceType.class, AppearanceType.NONE);
    _weaponType = set.getEnum("weaponType", WeaponType.class, WeaponType.NONE);
    _armorType = set.getEnum("armorType", ArmorType.class, ArmorType.NONE);
    _handType = set.getEnum("handType", AppearanceHandType.class, AppearanceHandType.NONE);
    _magicType = set.getEnum("magicType", AppearanceMagicType.class, AppearanceMagicType.NONE);

    final CrystalType crystalType = set.getEnum("crystalType", CrystalType.class, CrystalType.NONE);
    if (crystalType != CrystalType.NONE) {
      addCrystalType(crystalType);
    }
    final AppearanceTargetType targetType =
        set.getEnum("targetType", AppearanceTargetType.class, AppearanceTargetType.NONE);
    if (targetType != AppearanceTargetType.NONE) {
      addTargetType(targetType);
    }

    final int bodyPart = ItemTable.SLOTS.get(set.getString("bodyPart", "none"));
    if (bodyPart != L2Item.SLOT_NONE) {
      addBodyPart(bodyPart);
    }

    final Race race = set.getEnum("race", Race.class, Race.NONE);
    if (race != Race.NONE) {
      addRace(race);
    }

    final Race raceNot = set.getEnum("raceNot", Race.class, Race.NONE);
    if (raceNot != Race.NONE) {
      addRaceNot(raceNot);
    }
  }
Esempio n. 2
0
  protected Condition parseUsingCondition(Node n) {
    Condition cond = null;
    NamedNodeMap attrs = n.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
      Node a = attrs.item(i);
      switch (a.getNodeName().toLowerCase()) {
        case "kind":
          {
            int mask = 0;
            StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
            while (st.hasMoreTokens()) {
              int old = mask;
              String item = st.nextToken().trim();
              for (WeaponType wt : WeaponType.values()) {
                if (wt.name().equals(item)) {
                  mask |= wt.mask();
                }
              }

              for (ArmorType at : ArmorType.values()) {
                if (at.name().equals(item)) {
                  mask |= at.mask();
                }
              }

              if (old == mask) {
                _log.info("[parseUsingCondition=\"kind\"] Unknown item type name: " + item);
              }
            }
            cond = joinAnd(cond, new ConditionUsingItemType(mask));
            break;
          }
        case "slot":
          {
            int mask = 0;
            StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
            while (st.hasMoreTokens()) {
              int old = mask;
              String item = st.nextToken().trim();
              if (ItemTable.SLOTS.containsKey(item)) {
                mask |= ItemTable.SLOTS.get(item);
              }

              if (old == mask) {
                _log.info("[parseUsingCondition=\"slot\"] Unknown item slot name: " + item);
              }
            }
            cond = joinAnd(cond, new ConditionUsingSlotType(mask));
            break;
          }
        case "skill":
          {
            int id = Integer.parseInt(a.getNodeValue());
            cond = joinAnd(cond, new ConditionUsingSkill(id));
            break;
          }
        case "slotitem":
          {
            StringTokenizer st = new StringTokenizer(a.getNodeValue(), ";");
            int id = Integer.parseInt(st.nextToken().trim());
            int slot = Integer.parseInt(st.nextToken().trim());
            int enchant = 0;
            if (st.hasMoreTokens()) {
              enchant = Integer.parseInt(st.nextToken().trim());
            }
            cond = joinAnd(cond, new ConditionSlotItemId(slot, id, enchant));
            break;
          }
        case "weaponchange":
          {
            boolean val = Boolean.parseBoolean(a.getNodeValue());
            cond = joinAnd(cond, new ConditionChangeWeapon(val));
            break;
          }
      }
    }

    if (cond == null) {
      _log.severe("Unrecognized <using> condition in " + _file);
    }
    return cond;
  }