Esempio n. 1
0
  public ArmorRating getRating() {
    ServerArmorTemplate base = null;

    if (baseData instanceof ServerArmorTemplate) base = (ServerArmorTemplate) baseData;

    if (!rating.isLoaded()) {
      if (base == null) {
        return ArmorRating.from(0);
      } else {
        return base.getRating();
      }
    }

    return ArmorRating.from(rating.getValue());
  }
Esempio n. 2
0
    public int getEffectivenessMax() {
      SpecialProtectionObjectTemplate base = null;

      if (baseData instanceof SpecialProtectionObjectTemplate)
        base = (SpecialProtectionObjectTemplate) baseData;

      if (!effectiveness.isLoaded()) {
        if (base == null) {
          return 0;
        } else {
          return base.getEffectivenessMax();
        }
      }

      int value = this.effectiveness.getMaxValue();
      final byte delta = this.effectiveness.getDeltaType();

      if (delta == '+' || delta == '-' || delta == '_' || delta == '=') {
        int baseValue = 0;

        if (baseData != null) {
          if (base != null) baseValue = base.getEffectivenessMax();
        }

        if (delta == '+') value = baseValue + value;
        if (delta == '-') value = baseValue - value;
        if (delta == '=') value = baseValue + (int) (baseValue * (value / 100.0f));
        if (delta == '_') value = baseValue - (int) (baseValue * (value / 100.0f));
      }
      return value;
    }
Esempio n. 3
0
  public int getIntegrity() {
    ServerArmorTemplate base = null;

    if (baseData instanceof ServerArmorTemplate) base = (ServerArmorTemplate) baseData;

    if (!integrity.isLoaded()) {
      if (base == null) {
        return 0;
      } else {
        return base.getIntegrity();
      }
    }

    int value = this.integrity.getValue();
    final byte delta = this.integrity.getDeltaType();

    if (delta == '+' || delta == '-' || delta == '_' || delta == '=') {
      int baseValue = 0;

      if (baseData != null) {
        if (base != null) baseValue = base.getIntegrity();
      }

      if (delta == '+') value = baseValue + value;
      if (delta == '-') value = baseValue - value;
      if (delta == '=') value = baseValue + (int) (baseValue * (value / 100.0f));
      if (delta == '_') value = baseValue - (int) (baseValue * (value / 100.0f));
    }
    return value;
  }
Esempio n. 4
0
    public DamageType getType() {
      SpecialProtectionObjectTemplate base = null;

      if (baseData instanceof SpecialProtectionObjectTemplate)
        base = (SpecialProtectionObjectTemplate) baseData;

      if (!type.isLoaded()) {
        if (base == null) {
          return DamageType.from(0);
        } else {
          return base.getType();
        }
      }

      return DamageType.from(type.getValue());
    }
Esempio n. 5
0
    @Override
    protected void load(final Iff iff) {
      iff.enterForm();
      iff.enterChunk();
      final int paramCount = iff.readInt();
      iff.exitChunk();
      for (int i = 0; i < paramCount; ++i) {
        iff.enterChunk();
        final String parameterName = iff.readString();

        if ("type".equalsIgnoreCase(parameterName)) {
          type.loadFromIff(objectTemplateList, iff);
        } else if ("effectiveness".equalsIgnoreCase(parameterName)) {
          effectiveness.loadFromIff(objectTemplateList, iff);
        } else {
          LOGGER.trace("Unexpected parameter {}", parameterName);
        }

        iff.exitChunk();
      }
      iff.exitForm();
    }
Esempio n. 6
0
  @Override
  protected void load(final Iff iff) {
    if (iff.getCurrentName() != TAG_SERVERARMORTEMPLATE) {
      return;
    }

    iff.enterForm();
    templateVersion = iff.getCurrentName();

    if (templateVersion == Tag.TAG_DERV) {
      iff.enterForm();
      iff.enterChunk();
      final String baseFilename = iff.readString();
      iff.exitChunk();
      final ObjectTemplate base = objectTemplateList.fetch(baseFilename);
      Preconditions.checkNotNull(base, "was unable to load base template %s", baseFilename);
      if (baseData == base && base != null) {
        base.releaseReference();
      } else {
        if (baseData != null) baseData.releaseReference();
        baseData = base;
      }
      iff.exitForm();
      templateVersion = iff.getCurrentName();
    }

    iff.enterForm();
    iff.enterChunk();
    final int paramCount = iff.readInt();
    iff.exitChunk();
    for (int i = 0; i < paramCount; ++i) {
      iff.enterChunk();
      final String parameterName = iff.readString();

      if ("rating".equalsIgnoreCase(parameterName)) {
        rating.loadFromIff(objectTemplateList, iff);
      } else if ("integrity".equalsIgnoreCase(parameterName)) {
        integrity.loadFromIff(objectTemplateList, iff);
      } else if ("effectiveness".equalsIgnoreCase(parameterName)) {
        effectiveness.loadFromIff(objectTemplateList, iff);
      } else if ("specialProtection".equalsIgnoreCase(parameterName)) {
        specialProtection.clear();
        specialProtectionAppend = iff.readBoolean();
        int listCount = iff.readInt();
        for (int j = 0; j < listCount; ++j) {
          final StructParam<ObjectTemplate> newData = new StructParam<ObjectTemplate>();
          newData.loadFromIff(objectTemplateList, iff);
          specialProtection.add(newData);
        }
        specialProtectionLoaded = true;
      } else if ("vulnerability".equalsIgnoreCase(parameterName)) {
        vulnerability.loadFromIff(objectTemplateList, iff);
      } else if ("encumbrance".equalsIgnoreCase(parameterName)) {
        int listCount = iff.readInt();
        int j;
        for (j = 0; j < 3 && j < listCount; ++j)
          encumbrance[j].loadFromIff(objectTemplateList, iff);
        for (; j < listCount; ++j) {
          final IntegerParam dummy = new IntegerParam();
          dummy.loadFromIff(objectTemplateList, iff);
        }
      } else {
        LOGGER.trace("Unexpected parameter {}", parameterName);
      }

      iff.exitChunk();
    }
    iff.exitForm();
  }