Esempio n. 1
0
  /**
   * select items, which improve AC but are not type ARMOR
   *
   * @param item
   * @param subtype
   * @param property
   * @param equipped
   * @param merge
   * @param aPC
   * @param eh The ExportHandler to advise if there are no more items.
   * @return int
   */
  private static String _replaceTokenArmorItem(
      int item,
      String subtype,
      String property,
      int equipped,
      int merge,
      PlayerCharacter aPC,
      ExportHandler eh) {
    // select all pieces of equipment of status==equipped
    // filter all AC relevant stuff
    final List<Equipment> aArrayList = new ArrayList<>();

    for (Equipment eq : aPC.getEquipmentListInOutputOrder(merge)) {
      if (("".equals(subtype) || eq.isType(subtype))
          && ((equipped == 3)
              || ((equipped == 2) && !eq.isEquipped())
              || ((equipped == 1) && eq.isEquipped()))) {
        if (eq.altersAC(aPC) && !eq.isArmor() && !eq.isShield()) {
          aArrayList.add(eq);
        }
      }
    }

    if (item < aArrayList.size()) {
      final Equipment eq = aArrayList.get(item);
      return _writeArmorProperty(eq, property, aPC);
    }
    eh.setNoMoreItems(true);
    return "";
  }
Esempio n. 2
0
  private static String _writeArmorProperty(Equipment eq, String property, PlayerCharacter aPC) {
    CharacterDisplay display = aPC.getDisplay();
    StringBuilder ret = new StringBuilder();

    if (property.startsWith("NAME")) {
      if (eq.isEquipped() && !property.equals("NAMENOSTAR")) {
        ret.append("*");
      }

      ret.append(OutputNameFormatting.parseOutputName(eq, aPC));
      ret.append(eq.getAppliedName());
    } else if (property.startsWith("OUTPUTNAME")) {
      // TODO this appears to be the same as above.  Should be refactored
      if (eq.isEquipped()) {
        ret.append("*");
      }

      ret.append(OutputNameFormatting.parseOutputName(eq, aPC));
      ret.append(eq.getAppliedName());
    } else if (property.startsWith("TOTALAC") || property.startsWith("ACBONUS")) {
      // adjustments for new equipment modifier
      // EQMARMOR|AC|x|TYPE=ENHANCEMENT changed to COMBAT|AC|x|TYPE=Armor.ENHANCEMENT
      // FileAccess.write(output, Delta.toString(eq.getACMod()));
      String acMod = aPC.getControl(CControl.EQACMOD);
      if (acMod != null) {
        Object o = aPC.getLocal(eq, acMod);
        int intValue = ((Number) o).intValue();
        ret.append(Delta.toString(intValue));
      } else {
        ret.append(Delta.toString((int) eq.bonusTo(aPC, "COMBAT", "AC", true)));
      }
    } else if (property.startsWith("BASEAC")) {
      // adjustments for new equipment modifier
      // EQMARMOR|AC|x|TYPE=ENHANCEMENT changed to COMBAT|AC|x|TYPE=Armor.ENHANCEMENT
      // FileAccess.write(output, Delta.toString(eq.getACMod()));
      String baseMod = aPC.getControl(CControl.EQBASEACMOD);
      if (baseMod != null) {
        Object o = aPC.getLocal(eq, baseMod);
        int intValue = ((Number) o).intValue();
        ret.append(Delta.toString(intValue));
      } else {
        ret.append(Delta.toString((int) BonusCalc.charBonusTo(eq, "COMBAT", "AC", aPC)));
      }
    } else if (property.startsWith("MAXDEX")) {
      final int iMax = EqToken.getMaxDexTokenInt(aPC, eq);
      if (iMax != Constants.MAX_MAXDEX) {
        ret.append(Delta.toString(iMax));
      }
    } else if (property.startsWith("ACCHECK")) {
      ret.append(Delta.toString(EqToken.getAcCheckTokenInt(aPC, eq)));
    } else if (property.startsWith("EDR")) {
      ret.append(Delta.toString(EqToken.getEdrTokenInt(aPC, eq)));
    } else if (property.startsWith("ISTYPE")) {
      if (eq.isType(property.substring(property.indexOf(".") + 1))) {
        ret.append("TRUE");
      } else {
        ret.append("FALSE");
      }
    } else if (property.startsWith("SPELLFAIL")) {
      ret.append(EqToken.getSpellFailureTokenInt(aPC, eq));
    } else if (property.startsWith("MOVE")) {
      final StringTokenizer aTok = new StringTokenizer(eq.moveString(), ",", false);
      String tempString = "";

      if (("M".equals(display.getSize()) || "S".equals(display.getSize()))
          && (aTok.countTokens() > 0)) {
        tempString = aTok.nextToken();

        if ("S".equals(display.getSize()) && (aTok.countTokens() > 1)) {
          tempString = aTok.nextToken();
        }
      }

      ret.append(tempString);
    } else if (property.startsWith("SPROP")) {
      ret.append(eq.getSpecialProperties(aPC));
    } else if (property.startsWith("TYPE")) {
      String typeString = "";

      if (eq.isLight()) {
        typeString = "Light";
      } else if (eq.isMedium()) {
        typeString = "Medium";
      } else if (eq.isHeavy()) {
        typeString = "Heavy";
      } else if (eq.isShield()) {
        typeString = "Shield";
      } else if (eq.isExtra()) {
        typeString = "Extra";
      }

      ret.append(typeString);
    } else if (property.startsWith("WT")) {
      ret.append(BigDecimalHelper.trimZeros(eq.getWeight(aPC).toString()));
    }
    return ret.toString();
  }