示例#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 "";
  }
示例#2
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 "";
  }
示例#3
0
 public void export(ExportHandler theHandler, BufferedWriter buf) {
   Collection<PlayerCharacter> characters = new ArrayList<PlayerCharacter>();
   for (CharacterFacade character : this) {
     if (character instanceof CharacterFacadeImpl) {
       characters.add(((CharacterFacadeImpl) character).getTheCharacter());
     }
   }
   theHandler.write(characters, buf);
 }
示例#4
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;
  }
示例#5
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 "";
  }
示例#6
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 "";
  }
示例#7
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 "";
  }
  @Override
  protected void updateCharacterInfo() {
    if (theHandler == null) {
      return;
    }

    if (theSelectPanel != null) {
      theSelectPanel.refresh();
    }

    final StringWriter out = new StringWriter();
    final BufferedWriter buf = new BufferedWriter(out);
    theHandler.write(getPc(), buf);
    final String genText = out.toString().replace("preview_color.css", getColorCSS());
    ByteArrayInputStream instream = new ByteArrayInputStream(genText.getBytes());
    try {
      final URI root =
          new URI(
              "file",
              SettingsHandler.getPcgenPreviewDir().getAbsolutePath().replaceAll("\\\\", "/"),
              null);
      final Document doc =
          theDocBuilder.parse(new InputSourceImpl(instream, root.toString(), "UTF-8"));
      theSheetPanel.setDocument(doc, theRendererContext);
    } catch (Throwable e) {
      final String errorMsg = "<html><body>Unable to process sheet<br>" + e + "</body></html>";
      instream = new ByteArrayInputStream(errorMsg.getBytes());
      try {
        final Document doc = theDocBuilder.parse(instream);
        theSheetPanel.setDocument(doc, theRendererContext);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      Logging.errorPrint("Unable to process sheet: ", e);
    }
  }
示例#9
0
 public static void register(Token token) {
   if (!exportSet.contains(token)) {
     exportSet.add(token);
     ExportHandler.addToTokenMap(token);
   }
 }
示例#10
0
 public static void register(Token token) throws PersistenceLayerException {
   if (!exportSet.contains(token)) {
     exportSet.add(token);
     ExportHandler.addToTokenMap(token);
   }
 }