Exemplo n.º 1
0
  /**
   * select various stuff, that improves AC
   *
   * @param index
   * @param type
   * @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 _replaceTokenArmorVarious(
      int index,
      String type,
      String subtype,
      String property,
      int equipped,
      int merge,
      PlayerCharacter aPC,
      ExportHandler eh) {
    final List<Equipment> aArrayList = new ArrayList<>();

    for (Equipment eq : aPC.getEquipmentOfTypeInOutputOrder(type, subtype, equipped, merge)) {
      if (eq.getACMod(aPC).intValue() > 0) {
        aArrayList.add(eq);
      } else if (eq.altersAC(aPC)) {
        aArrayList.add(eq);
      }
    }

    if (index < aArrayList.size()) {
      final Equipment eq = aArrayList.get(index);
      return _writeArmorProperty(eq, property, aPC);
    }
    eh.setNoMoreItems(true);
    return "";
  }
Exemplo n.º 2
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 "";
  }
Exemplo n.º 3
0
  /**
   * select shirts
   *
   * @param shirt
   * @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 _replaceTokenArmorShirt(
      int shirt,
      String subtype,
      String property,
      int equipped,
      int merge,
      PlayerCharacter aPC,
      ExportHandler eh) {
    final List<Equipment> aArrayList =
        aPC.getEquipmentOfTypeInOutputOrder("Shirt", subtype, equipped, merge);

    if (shirt < aArrayList.size()) {
      final Equipment eq = aArrayList.get(shirt);
      return _writeArmorProperty(eq, property, aPC);
    }
    eh.setNoMoreItems(true);
    return "";
  }
Exemplo n.º 4
0
  /**
   * select suits - shields
   *
   * @param armor
   * @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 _replaceTokenArmor(
      int armor, String property, int equipped, int merge, PlayerCharacter aPC, ExportHandler eh) {
    final List<Equipment> aArrayList =
        aPC.getEquipmentOfTypeInOutputOrder("Armor", equipped, merge);
    final List<Equipment> bArrayList =
        aPC.getEquipmentOfTypeInOutputOrder("Shield", equipped, merge);

    for (Equipment eq : bArrayList) {
      aArrayList.remove(eq);
    }

    if (armor < aArrayList.size()) {
      final Equipment eq = aArrayList.get(armor);
      return _writeArmorProperty(eq, property, aPC);
    }
    eh.setNoMoreItems(true);
    return "";
  }
Exemplo n.º 5
0
  /**
   * select suits
   *
   * @param suit
   * @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 _replaceTokenArmorSuit(
      int suit,
      String subtype,
      String property,
      int equipped,
      int merge,
      PlayerCharacter aPC,
      ExportHandler eh) {
    final List<Equipment> aArrayList =
        aPC.getEquipmentOfTypeInOutputOrder("Suit", subtype, equipped, merge);

    //
    // Temporary hack until someone gets around to fixing it properly
    //
    // aArrayList.addAll(aPC.getEquipmentOfTypeInOutputOrder("Shirt", subtype, equipped));

    if (suit < aArrayList.size()) {
      final Equipment eq = aArrayList.get(suit);
      return _writeArmorProperty(eq, property, aPC);
    }
    eh.setNoMoreItems(true);
    return "";
  }
Exemplo n.º 6
0
  /**
   * Select the target skill based on the supplied critieria. Searches through the characters skill
   * list selecting those that start with the value in details.properties[0] and then uses the index
   * in details.skillId to select the skill.
   *
   * @param tokenSource The token being processed. Used for error reporting.
   * @param pc The character being processed.
   * @param details The parsed details of the token.
   * @param eh The ExportHandler
   * @return The matching skill, or null if none match.
   */
  private Skill getSkill(
      String tokenSource, PlayerCharacter pc, SkillDetails details, ExportHandler eh) {
    int skillIndex;

    // Get the index
    try {
      skillIndex = Integer.parseInt(details.getSkillId());
    } catch (NumberFormatException exc) {
      Logging.errorPrint("Error replacing SKILLSUBSET." + tokenSource, exc);
      return null;
    }

    // Build the list of matching skills
    String skillPrefix = details.getProperty(0);
    int prefixLength = skillPrefix.length();
    List<Skill> skillSubset = new ArrayList<>();
    final List<Skill> skills =
        SkillDisplay.getSkillListInOutputOrder(
            pc, pc.getDisplay().getPartialSkillList(View.VISIBLE_EXPORT));

    for (Skill bSkill : skills) {
      if (skillPrefix.regionMatches(true, 0, bSkill.getKeyName(), 0, prefixLength)) {
        skillSubset.add(bSkill);
      }
    }

    // Select the skill
    if ((skillIndex >= (skillSubset.size() - 1)) && eh != null && eh.getExistsOnly()) {
      eh.setNoMoreItems(true);
    }

    Skill aSkill = null;
    if (skillIndex <= (skillSubset.size() - 1)) {
      aSkill = skillSubset.get(skillIndex);
    }
    return aSkill;
  }