Ejemplo n.º 1
0
  @Override
  public void previewSpells() {
    boolean aBool = SettingsHandler.getPrintSpellsWithPC();
    SettingsHandler.setPrintSpellsWithPC(true);

    String templateFileName =
        PCGenSettings.getInstance().getProperty(PCGenSettings.SELECTED_SPELL_SHEET_PATH);
    if (StringUtils.isEmpty(templateFileName)) {
      delegate.showErrorMessage(
          Constants.APPLICATION_NAME, LanguageBundle.getString("in_spellNoSheet")); // $NON-NLS-1$
      return;
    }
    File templateFile = new File(templateFileName);

    File outputFile = BatchExporter.getTempOutputFilename(templateFile);

    boolean success;
    if (ExportUtilities.isPdfTemplate(templateFile)) {
      success = BatchExporter.exportCharacterToPDF(pcFacade, outputFile, templateFile);
    } else {
      success = BatchExporter.exportCharacterToNonPDF(pcFacade, outputFile, templateFile);
    }
    if (success) {
      try {
        Utility.viewInBrowser(outputFile);
      } catch (IOException e) {
        Logging.errorPrint("SpellSupportFacadeImpl.previewSpells failed", e);
        delegate.showErrorMessage(
            Constants.APPLICATION_NAME,
            LanguageBundle.getString("in_spellPreviewFail")); // $NON-NLS-1$
      }
    }
    SettingsHandler.setPrintSpellsWithPC(aBool);
  }
  /* (non-Javadoc)
   * @see pcgen.AbstractCharacterTestCase#setUp()
   */
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    dataset = new MockDataSetFacade();
    dataset.addEquipmentLocation(new BodyStructure(Constants.EQUIP_LOCATION_EQUIPPED, true));
    dataset.addEquipmentLocation(new BodyStructure(LOC_HANDS, false));
    dataset.addEquipmentLocation(new BodyStructure(LOC_BODY, false));
    if (SystemCollections.getUnmodifiableEquipSlotList().isEmpty()) {
      EquipSlot equipSlot = new EquipSlot();
      equipSlot.setSlotName(SLOT_WEAPON);
      equipSlot.addContainedType("Weapon");
      equipSlot.setContainNum(1);
      equipSlot.setSlotNumType("HANDS");
      SystemCollections.addToEquipSlotsList(equipSlot, SettingsHandler.getGame().getName());
      Globals.setEquipSlotTypeCount("HANDS", "2");

      equipSlot = new EquipSlot();
      equipSlot.setSlotName(SLOT_RING);
      equipSlot.addContainedType("Ring");
      equipSlot.setContainNum(2);
      equipSlot.setSlotNumType("BODY");
      SystemCollections.addToEquipSlotsList(equipSlot, SettingsHandler.getGame().getName());
      Globals.setEquipSlotTypeCount("BODY", "1");
    }
    uiDelegate = new MockUIDelegate();
  }
Ejemplo n.º 3
0
 public void refresh() {
   if (SettingsHandler.getGame() != theGameMode) {
     theSheetDir =
         SettingsHandler.getPcgenPreviewDir()
             + File.separator
             + SettingsHandler.getGame().getPreviewDir();
     buildCombo();
   }
 }
Ejemplo n.º 4
0
  CharacterSheetSelectionPanel(final InfoCharacterSheet aParent) {
    theParent = aParent;

    theGameMode = SettingsHandler.getGame();

    theSheetDir =
        SettingsHandler.getPcgenPreviewDir()
            + File.separator
            + SettingsHandler.getGame().getPreviewDir();
    initComponents();
  }
Ejemplo n.º 5
0
 public void itemStateChanged(final ItemEvent e) {
   if (!initialized) {
     return;
   }
   final JComboBox combo = (JComboBox) e.getSource();
   if (e.getStateChange() == ItemEvent.SELECTED) {
     final String csheet = (String) combo.getSelectedItem();
     SettingsHandler.setPCGenOption(
         "InfoCharacterSheet." + SettingsHandler.getGame().getName() + ".CurrentSheet", csheet);
     final File template = new File(theSheetDir + File.separator + csheet);
     theParent.setSheet(template);
   }
 }
Ejemplo n.º 6
0
  /** Remove any temporary xml files produced while outputting characters. */
  static void removeTemporaryFiles() {
    final boolean cleanUp =
        UIPropertyContext.getInstance().initBoolean(UIPropertyContext.CLEANUP_TEMP_FILES, true);

    if (!cleanUp) {
      return;
    }

    final String aDirectory = SettingsHandler.getTempPath() + File.separator;
    new File(aDirectory)
        .list(
            new FilenameFilter() {
              @Override
              public boolean accept(File aFile, String aString) {
                try {
                  if (aString.startsWith(Constants.TEMPORARY_FILE_NAME)) {
                    final File tf = new File(aFile, aString);
                    tf.delete();
                  }
                } catch (Exception e) {
                  Logging.errorPrint("removeTemporaryFiles", e);
                }

                return false;
              }
            });
  }
Ejemplo n.º 7
0
 private String getColorCSS() {
   int value =
       SettingsHandler.getGMGenOption(
           CharacterSheetPlugin.LOG_NAME + ".color", CharacterPanel.BLUE);
   switch (value) {
     case CharacterPanel.BLUE:
       return "preview_color_blue.css";
     case CharacterPanel.LIGHTBLUE:
       return "preview_color_light_blue.css";
     case CharacterPanel.GREEN:
       return "preview_color_green.css";
     case CharacterPanel.LIGHTGREEN:
       return "preview_color_light_green.css";
     case CharacterPanel.RED:
       return "preview_color_red.css";
     case CharacterPanel.LIGHTRED:
       return "preview_color_light_red.css";
     case CharacterPanel.YELLOW:
       return "preview_color_yellow.css";
     case CharacterPanel.LIGHTYELLOW:
       return "preview_color_light_yellow.css";
     case CharacterPanel.GREY:
       return "preview_color_grey.css";
     case CharacterPanel.LIGHTGREY:
       return "preview_color_light_grey.css";
     default:
       return "preview_color_blue.css";
   }
 }
Ejemplo n.º 8
0
  /** Rolls an initiative check for the whole list */
  public void check() {
    Dice d20 = new Dice(1, 20);
    boolean pcroll =
        SettingsHandler.getGMGenOption(InitiativePlugin.LOG_NAME + ".rollPCInitiatives", true);

    for (InitHolder c : this) {
      int roll = d20.roll();
      boolean doroll = true;
      if (!pcroll && c instanceof Combatant) {
        Combatant com = (Combatant) c;
        if (com.getCombatantType().equals("PC")) {
          doroll = false;
        }
      }

      if (doroll) {
        c.getInitiative().checkExtRoll(roll);
      } else {
        c.getInitiative().resetCurrentInitiative();
      }
    }

    this.sort();

    calculateNumberField();
  }
  /**
   * @see pcgen.io.exporttoken.Token#getToken(java.lang.String, pcgen.core.PlayerCharacter,
   *     pcgen.io.ExportHandler)
   */
  @Override
  public String getToken(String tokenSource, PlayerCharacter pc, ExportHandler eh) {
    final StringTokenizer aTok = new StringTokenizer(tokenSource, ".");
    // Skip the ABILITYLIST token itself
    final String tokenString = aTok.nextToken();
    final String catString = aTok.nextToken();
    final AbilityCategory aCategory = SettingsHandler.getGame().getAbilityCategory(catString);

    return getTokenForCategory(pc, aTok, tokenString, aCategory);
  }
Ejemplo n.º 10
0
  private void buildCombo() {
    final File sheetDir = new File(theSheetDir);
    final File[] fileList = sheetDir.listFiles();
    if (fileList == null) {
      Logging.errorPrint("Could not find preview sheet directory " + theSheetDir);
      return;
    }

    for (int i = 0; i < fileList.length; ++i) {
      if (!fileList[i].isDirectory() && !fileList[i].isHidden()) {
        theCombo.addItem(fileList[i].getName());
      }
    }

    final String csheet =
        SettingsHandler.getPCGenOption(
            "InfoCharacterSheet." + SettingsHandler.getGame().getName() + ".CurrentSheet",
            SettingsHandler.getGame().getDefaultPreviewSheet());
    final File template = new File(theSheetDir + File.separator + csheet);
    theCombo.setSelectedItem(template.getName());
    theParent.setSheet(template);
  }
Ejemplo n.º 11
0
 /**
  * @see pcgen.io.exporttoken.AbilityListToken#getAbilityList(pcgen.core.PlayerCharacter,
  *     pcgen.core.AbilityCategory)
  */
 @Override
 protected MapToList<Ability, CNAbility> getAbilityList(
     PlayerCharacter pc, final AbilityCategory aCategory) {
   final MapToList<Ability, CNAbility> listOfAbilities = new HashMapToList<>();
   Collection<AbilityCategory> allCats = SettingsHandler.getGame().getAllAbilityCategories();
   for (AbilityCategory aCat : allCats) {
     if (AbilityCategory.ANY.equals(aCategory) || aCat.getParentCategory().equals(aCategory)) {
       for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.VIRTUAL)) {
         listOfAbilities.addToListFor(cna.getAbility(), cna);
       }
     }
   }
   return listOfAbilities;
 }
Ejemplo n.º 12
0
  /*
   * @see TestCase#setUp()
   */
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    LoadContext context = Globals.getContext();

    SettingsHandler.getGame().setSpellBaseDC("10+SPELLLEVEL+BASESPELLSTAT");

    SimpleLoader<BonusSpellInfo> bonusSpellLoader =
        new SimpleLoader<BonusSpellInfo>(BonusSpellInfo.class);
    try {
      URI testURI = new URI("file:/" + getClass().getName() + ".java");
      bonusSpellLoader.parseLine(context, "1	BASESTATSCORE:12	STATRANGE:8", testURI);
      bonusSpellLoader.parseLine(context, "2	BASESTATSCORE:14	STATRANGE:8", testURI);
      bonusSpellLoader.parseLine(context, "3	BASESTATSCORE:16	STATRANGE:8", testURI);
    } catch (URISyntaxException e) {
      throw new UnreachableError(e);
    }

    // Human
    human = new Race();

    final BonusObj bon = Bonus.newBonus(context, "FEAT|POOL|2");
    human.addToListFor(ListKey.BONUS, bon);

    arcaneClass = new PCClass();
    arcaneClass.setName("TestArcane");
    arcaneClass.put(StringKey.SPELLTYPE, "ARCANE");
    context.unconditionallyProcess(arcaneClass, "SPELLSTAT", "CHA");
    arcaneClass.put(ObjectKey.SPELLBOOK, false);
    arcaneClass.put(ObjectKey.MEMORIZE_SPELLS, false);
    context.unconditionallyProcess(arcaneClass.getOriginalClassLevel(1), "KNOWN", "4,2,1");
    context.unconditionallyProcess(arcaneClass.getOriginalClassLevel(1), "CAST", "3,1,0");
    context.getReferenceContext().importObject(arcaneClass);

    divineClass = new PCClass();
    divineClass.setName("TestDivine");
    divineClass.put(StringKey.SPELLTYPE, "DIVINE");
    context.unconditionallyProcess(divineClass, "SPELLSTAT", "WIS");
    divineClass.put(ObjectKey.SPELLBOOK, false);
    divineClass.put(ObjectKey.MEMORIZE_SPELLS, true);
    context.unconditionallyProcess(divineClass.getOriginalClassLevel(1), "CAST", "3,1,0");
    context.unconditionallyProcess(
        divineClass, "SPELLLEVEL", "CLASS|SPELLCASTER.Divine=1|Cure Light Wounds");
    context.getReferenceContext().importObject(divineClass);
    context.resolveDeferredTokens();
    context.getReferenceContext().buildDerivedObjects();
    context.getReferenceContext().resolveReferences(null);
  }
Ejemplo n.º 13
0
  /**
   * Beep and print error message if PCGen is debugging.
   *
   * @param s String error message
   * @param context the LoadContext containing the deprecated resource
   */
  public static void deprecationPrint(final String s, final LoadContext context) {
    if (isDebugMode()) {
      s_TOOLKIT.beep();
    }

    Logger l = getLogger();
    if (l.isLoggable(LST_WARNING) && SettingsHandler.outputDeprecationMessages()) {
      if (context != null
          && context.getObjectContext() != null
          && context.getObjectContext().getSourceURI() != null) {
        l.log(LST_WARNING, s + " (Source: " + context.getObjectContext().getSourceURI() + " )");
      } else {
        l.log(LST_WARNING, s);
      }
    }
  }
Ejemplo n.º 14
0
  /**
   * Get a temporary file name for outputting a character using a particular output template.
   *
   * @param templateFile The output template that will be used.
   * @return The temporary file, or null if it could not be created.
   */
  public static File getTempOutputFilename(File templateFile) {
    String extension =
        ExportUtilities.getOutputExtension(
            templateFile.getName(), ExportUtilities.isPdfTemplate(templateFile));

    try {
      // create a temporary file to view the character output
      return File.createTempFile(
          Constants.TEMPORARY_FILE_NAME, "." + extension, SettingsHandler.getTempPath());
    } catch (IOException ioe) {
      ShowMessageDelegate.showMessageDialog(
          "Could not create temporary preview file.", "PCGen", MessageType.ERROR);
      Logging.errorPrint("Could not create temporary preview file.", ioe);
      return null;
    }
  }
Ejemplo n.º 15
0
 private static synchronized void staticSetUp() {
   if (!staticDone) {
     SettingsHandler.getGame().clearLoadContext();
     AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
     t = BuildUtilities.createSize("Tiny", 0);
     ref.importObject(t);
     s = BuildUtilities.createSize("Small", 1);
     ref.importObject(s);
     m = BuildUtilities.createSize("Medium", 2);
     m.put(ObjectKey.IS_DEFAULT_SIZE, true);
     ref.importObject(m);
     l = BuildUtilities.createSize("Large", 3);
     ref.importObject(l);
     h = BuildUtilities.createSize("Huge", 4);
     ref.importObject(h);
     staticDone = true;
   }
 }
Ejemplo n.º 16
0
 /**
  * Decodes the given String into an AbilitySelection. The String format to be passed into this
  * method is defined solely by the return result of the getPersistentFormat method. There is no
  * guarantee that the encoding is human readable, simply that the encoding is uniquely identifying
  * such that this method is capable of decoding the String into an AbilitySelection.
  *
  * @param persistentFormat The String which should be decoded to provide an AbilitySelection.
  * @return An AbilitySelection that was encoded in the given String.
  */
 public static AbilitySelection getAbilitySelectionFromPersistentFormat(
     LoadContext context, String persistentFormat) {
   StringTokenizer st = new StringTokenizer(persistentFormat, Constants.PIPE);
   String catString = st.nextToken();
   if (!catString.startsWith("CATEGORY=")) {
     throw new IllegalArgumentException(
         "String in getAbilitySelectionFromPersistentFormat "
             + "must start with CATEGORY=, found: "
             + persistentFormat);
   }
   String cat = catString.substring(9);
   AbilityCategory ac = SettingsHandler.getGame().getAbilityCategory(cat);
   if (ac == null) {
     throw new IllegalArgumentException(
         "Category in getAbilitySelectionFromPersistentFormat " + "must exist found: " + cat);
   }
   String ab = st.nextToken();
   Ability a =
       context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, ac, ab);
   if (a == null) {
     throw new IllegalArgumentException(
         "Second argument in String in getAbilitySelectionFromPersistentFormat "
             + "must be an Ability, but it was not found: "
             + persistentFormat);
   }
   String sel = null;
   if (st.hasMoreTokens()) {
     /*
      * No need to check for MULT:YES/NO here, as that is checked
      * implicitly in the construction of AbilitySelection below
      */
     sel = st.nextToken();
   } else if (persistentFormat.endsWith(Constants.PIPE)) {
     // Handle the StringTokenizer ignoring blank tokens at the end
     sel = "";
   }
   if (st.hasMoreTokens()) {
     throw new IllegalArgumentException(
         "String in getAbilitySelectionFromPersistentFormat "
             + "must have 2 or 3 arguments, but found more: "
             + persistentFormat);
   }
   return new AbilitySelection(a, sel);
 }
Ejemplo n.º 17
0
  /**
   * Write a PDF party sheet for the characters in the party to the output file. The party sheet
   * will be built according to the template file. If the output file exists it will be overwritten.
   *
   * @param party The already loaded party of characters to be output.
   * @param outFile The file to which the party sheet is to be written.
   * @param templateFile The file that has the export template definition.
   * @return true if the export was successful, false if it failed in some way.
   */
  public static boolean exportPartyToPDF(PartyFacade party, File outFile, File templateFile) {
    // We want the non pdf extension here for the intermediate file.
    String templateExtension = ExportUtilities.getOutputExtension(templateFile.getName(), false);
    boolean isTransformTemplate =
        "xslt".equalsIgnoreCase(templateExtension) || "xsl".equalsIgnoreCase(templateExtension);

    boolean useTempFile =
        PCGenSettings.OPTIONS_CONTEXT.initBoolean(
            PCGenSettings.OPTION_GENERATE_TEMP_FILE_WITH_PDF, false);
    String outFileName = FilenameUtils.removeExtension(outFile.getAbsolutePath());
    File tempFile =
        isTransformTemplate ? new File(outFileName + ".xml") : new File(outFileName + ".fo");
    try (BufferedOutputStream fileStream = new BufferedOutputStream(new FileOutputStream(outFile));
        ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
        OutputStream exportOutput =
            useTempFile
                // Output to both the byte stream and to the temp file.
                ? new TeeOutputStream(byteOutputStream, new FileOutputStream(tempFile))
                : byteOutputStream) {
      FopTask task;
      if (isTransformTemplate) {
        exportParty(party, exportOutput);
        ByteArrayInputStream inputStream = new ByteArrayInputStream(byteOutputStream.toByteArray());
        task = FopTask.newFopTask(inputStream, templateFile, fileStream);
      } else {
        SettingsHandler.setSelectedPartyPDFOutputSheet(templateFile.getAbsolutePath());

        exportParty(party, templateFile, exportOutput);
        ByteArrayInputStream inputStream = new ByteArrayInputStream(byteOutputStream.toByteArray());
        task = FopTask.newFopTask(inputStream, null, fileStream);
      }
      task.run();
    } catch (IOException e) {
      Logging.errorPrint("BatchExporter.exportPartyToPDF failed", e);
      return false;
    } catch (ExportException e) {
      Logging.errorPrint("BatchExporter.exportPartyToPDF failed", e);
      return false;
    }
    return true;
  }
Ejemplo n.º 18
0
 private void formComponentShown() {
   if (!theHasBeenSizedFlag) {
     theHasBeenSizedFlag = true;
     if (theSplitPane != null) {
       final int s =
           SettingsHandler.getPCGenOption(
               "InfoCharacterSheet." + "splitLeftRight", // $NON-NLS-1$
               (int) ((this.getSize().getWidth() * 6) / 10));
       theSplitPane.setDividerLocation(s);
       theSplitPane.addPropertyChangeListener(
           JSplitPane.DIVIDER_LOCATION_PROPERTY,
           new PropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent anEvt) {
               SettingsHandler.setPCGenOption(
                   "InfoCharacterSheet." + "splitLeftRight", // $NON-NLS-1$
                   anEvt.getNewValue().toString());
             }
           });
     }
   }
 }
Ejemplo n.º 19
0
  @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);
    }
  }
Ejemplo n.º 20
0
 /** Flip the state of tooltips to that described by the global isToolTipTextShown. */
 public static void handleToolTipShownStateChange() {
   ToolTipManager.sharedInstance().setEnabled(SettingsHandler.isToolTipTextShown());
 }
Ejemplo n.º 21
0
  /**
   * Builds up a string describing what makes up the misc modifier for a skill for a character. This
   * can either be in long form '+2[skill TUMBLE gteq 5|TYPE=SYNERGY.STACK]' or in short form
   * '+2[TUMBLE]'. Any modifiers that cannot be determined will be displayed as a single entry of
   * 'OTHER'.
   *
   * @param aPC The character associated with this skill.
   * @param shortForm True if the abbreviated form should be used.
   * @return The explanation of the misc modifier's make-up.
   */
  public static String getModifierExplanation(Skill sk, PlayerCharacter aPC, boolean shortForm) {
    double bonusObjTotal = 0.0;
    List<String> explanation = new ArrayList<>();
    String keyName = sk.getKeyName();
    String bonusKey = ("SKILL." + keyName).toUpperCase();
    for (BonusObj bonus : aPC.getActiveBonusList()) {
      // calculate bonus and add to activeBonusMap
      if (aPC.isApplied(bonus) && "SKILL".equals(bonus.getBonusName())) {
        boolean include = bonusForThisSkill(bonus, keyName);
        if (!include) {
          for (BonusPair bp : aPC.getStringListFromBonus(bonus)) {
            String bpKey = bp.fullyQualifiedBonusType.toUpperCase();
            if (bpKey.equals(bonusKey)) {
              include = true;
              break;
            }
          }
        }

        if (include) {
          double iBonus = 0;
          for (BonusPair bp : aPC.getStringListFromBonus(bonus)) {
            String bpKey = bp.fullyQualifiedBonusType.toUpperCase();
            if (bpKey.startsWith(bonusKey)) {
              iBonus += bp.resolve(aPC).doubleValue();
            }
          }
          if (!CoreUtility.doublesEqual(iBonus, 0.0)) {
            explanation.add(Delta.toString((int) iBonus) + aPC.getBonusContext(bonus, shortForm));
            bonusObjTotal += iBonus;
          }
        }
      }
    }

    StringBuilder bonusDetails = new StringBuilder();
    bonusDetails.append(StringUtil.joinToStringBuilder(explanation, " "));

    // TODO: Need to add other bonuses which are not encoded as bonus
    // objects
    // - familiars, racial, feats - and add them to bonusObjTotal

    double bonus;
    CDOMSingleRef<PCStat> statref = sk.get(ObjectKey.KEY_STAT);
    if (statref != null) {
      PCStat stat = statref.get();
      bonus = aPC.getStatModFor(stat);
      bonus += aPC.getTotalBonusTo("SKILL", "STAT." + stat.getKeyName());
      SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "STAT");
    }

    // The catch-all for non-bonusObj modifiers.
    bonus = aPC.getTotalBonusTo("SKILL", keyName) - bonusObjTotal;
    SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "OTHER");

    // loop through all current skill types checking for boni
    for (Type singleType : sk.getTrueTypeList(false)) {
      bonus = aPC.getTotalBonusTo("SKILL", "TYPE." + singleType);
      SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "TYPE." + singleType);
    }

    // now check for any lists of skills, etc
    bonus = aPC.getTotalBonusTo("SKILL", "LIST");
    SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "LIST");

    // now check for ALL
    bonus = aPC.getTotalBonusTo("SKILL", "ALL");
    SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "ALL");

    // these next two if-blocks try to get BONUS:[C]CSKILL|TYPE=xxx|y to
    // function
    if (aPC.isClassSkill(sk)) {
      bonus = aPC.getTotalBonusTo("CSKILL", keyName);
      SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "CSKILL");

      // loop through all current skill types checking for boni
      for (Type singleType : sk.getTrueTypeList(false)) {
        bonus = aPC.getTotalBonusTo("CSKILL", "TYPE." + singleType);
        SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "CSKILL");
      }

      bonus = aPC.getTotalBonusTo("CSKILL", "LIST");
      SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "CSKILL");
    }

    if (!aPC.isClassSkill(sk) && !sk.getSafe(ObjectKey.EXCLUSIVE)) {
      bonus = aPC.getTotalBonusTo("CCSKILL", keyName);
      SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "CCSKILL");

      // loop through all current skill types checking for boni
      for (Type singleType : sk.getTrueTypeList(false)) {
        bonus = aPC.getTotalBonusTo("CCSKILL", "TYPE." + singleType);
        SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "CCSKILL");
      }

      bonus = aPC.getTotalBonusTo("CCSKILL", "LIST");
      SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "CCSKILL");
    }

    // Encumbrance
    int aCheckMod = sk.getSafe(ObjectKey.ARMOR_CHECK).calculateBonus(aPC);
    SkillCostDisplay.appendBonusDesc(bonusDetails, aCheckMod, "ARMOR");

    String aString = SettingsHandler.getGame().getRankModFormula();
    if (!aString.isEmpty()) {
      aString =
          aString.replaceAll(
              Pattern.quote("$$RANK$$"), SkillRankControl.getTotalRank(aPC, sk).toString());
      bonus = aPC.getVariableValue(aString, "").intValue();
      SkillCostDisplay.appendBonusDesc(bonusDetails, bonus, "RANKS");
    }

    return bonusDetails.toString();
  }
  /**
   * Produce the ABILITY token output for a specific ability category.
   *
   * @param pc The character being processed.
   * @param aTok The tokenised request, already past the category.
   * @param tokenString The output token requested
   * @param aCategory The ability category being output.
   * @return The token value.
   */
  protected String getTokenForCategory(
      PlayerCharacter pc,
      final StringTokenizer aTok,
      final String tokenString,
      final AbilityCategory aCategory) {
    if (aCategory == null) {
      return "";
    }
    StringBuilder retString = new StringBuilder();
    // If we haven't cached some of the processign data, then do so, this is so that
    // if the Output Sheet loops over this token we don't process one-off stuff more than
    // once
    if (lastPC != pc
        || !aCategory.equals(lastCategory)
        || lastPCSerial != pc.getSerial()
        || !tokenString.equals(lastType)) {
      Collection<AbilityCategory> cats =
          SettingsHandler.getGame().getAllAbilityCatsForKey(aCategory.getKeyName());
      abilityList = new ArrayList<Ability>();
      for (AbilityCategory abilityCategory : cats) {
        abilityList.addAll(getAbilityList(pc, abilityCategory));
      }
      lastPC = pc;
      lastCategory = aCategory;
      lastPCSerial = pc.getSerial();
      lastType = tokenString;
    }

    // Default values
    List<String> types = new ArrayList<String>();
    List<String> negate = new ArrayList<String>();
    String aspect = null;

    while (aTok.hasMoreTokens()) {
      final String typeStr = aTok.nextToken();

      int typeInd = typeStr.indexOf("TYPE=");
      if (typeInd != -1 && typeStr.length() > 5) {
        if (typeInd > 0) {
          negate.add(typeStr.substring(typeInd + 5));
        } else {
          types.add(typeStr.substring(typeInd + 5));
        }
      }

      int aspectInd = typeStr.indexOf("ASPECT=");
      if (aspectInd != -1 && typeStr.length() > 7) {
        aspect = typeStr.substring(aspectInd + 7);
      }
    }

    List<Ability> aList =
        AbilityToken.buildAbilityList(
            types, negate, null, AbilityToken.ABILITY_VISIBLE, aspect, abilityList);

    boolean needComma = false;
    for (Ability ability : aList) {
      if (needComma) {
        retString.append(DELIM);
      }
      needComma = true;

      retString.append(QualifiedName.qualifiedName(pc, ability));
    }

    return retString.toString();
  }
Ejemplo n.º 23
0
 public void initPreferences() {
   setMaxHP(SettingsHandler.getGMGenOption(InitiativePlugin.LOG_NAME + ".dbMaxHP", 100));
   setNumber(SettingsHandler.getGMGenOption(InitiativePlugin.LOG_NAME + ".dbMaxNum", 20));
 }
Ejemplo n.º 24
0
 public void applyPreferences() {
   SettingsHandler.setGMGenOption(InitiativePlugin.LOG_NAME + ".dbMaxHP", getMaxHP());
   SettingsHandler.setGMGenOption(InitiativePlugin.LOG_NAME + ".dbMaxNum", getNumber());
   initiative.applyPrefs();
   initiative.refreshTable();
 }
Ejemplo n.º 25
0
 /**
  * Get the VALUE sub token
  *
  * @param pc
  * @return the VALUE sub token
  */
 public static String getValueToken(PlayerCharacter pc) {
   return BigDecimalHelper.trimZeros(pc.totalValue())
       + " "
       + SettingsHandler.getGame().getCurrencyDisplay();
 }
Ejemplo n.º 26
0
  /* (non-Javadoc)
   * @see pcgen.gui2.prefs.PreferencesPanel#initPreferences()
   */
  @Override
  public void applyOptionValuesToControls() {
    switch (SettingsHandler.getTabPlacement()) {
      case SwingConstants.TOP:
        mainTabPlacementCombo.setSelectedIndex(0);

        break;

      case SwingConstants.BOTTOM:
        mainTabPlacementCombo.setSelectedIndex(1);

        break;

      case SwingConstants.LEFT:
        mainTabPlacementCombo.setSelectedIndex(2);

        break;

      case SwingConstants.RIGHT:
        mainTabPlacementCombo.setSelectedIndex(3);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.applyOptionValuesToControls (tab placement) the tab option "
                + SettingsHandler.getTabPlacement()
                + " is unsupported.");

        break;
    }

    switch (SettingsHandler.getChaTabPlacement()) {
      case SwingConstants.TOP:
        charTabPlacementCombo.setSelectedIndex(0);

        break;

      case SwingConstants.BOTTOM:
        charTabPlacementCombo.setSelectedIndex(1);

        break;

      case SwingConstants.LEFT:
        charTabPlacementCombo.setSelectedIndex(2);

        break;

      case SwingConstants.RIGHT:
        charTabPlacementCombo.setSelectedIndex(3);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.applyOptionValuesToControls (cha tab placement) the tab option "
                + SettingsHandler.getChaTabPlacement()
                + " is unsupported.");

        break;
    }

    switch (SettingsHandler.getNameDisplayStyle()) {
      case Constants.DISPLAY_STYLE_NAME:
        tabLabelsCombo.setSelectedIndex(0);

        break;

      case Constants.DISPLAY_STYLE_NAME_CLASS:
        tabLabelsCombo.setSelectedIndex(1);

        break;

      case Constants.DISPLAY_STYLE_NAME_RACE:
        tabLabelsCombo.setSelectedIndex(2);

        break;

      case Constants.DISPLAY_STYLE_NAME_RACE_CLASS:
        tabLabelsCombo.setSelectedIndex(3);

        break;

      case Constants.DISPLAY_STYLE_NAME_FULL:
        tabLabelsCombo.setSelectedIndex(4);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.applyOptionValuesToControls (name display style) the tab option "
                + SettingsHandler.getNameDisplayStyle()
                + " is unsupported.");

        break;
    }

    displayAbilitiesAsTab.setSelected(SettingsHandler.isAbilitiesShownAsATab());
    expertGUICheckBox.setSelected(SettingsHandler.isExpertGUI());
  }
Ejemplo n.º 27
0
  /* (non-Javadoc)
   * @see pcgen.gui2.prefs.PreferencesPanel#applyPreferences()
   */
  @Override
  public void setOptionsBasedOnControls() {
    switch (mainTabPlacementCombo.getSelectedIndex()) {
      case 0:
        SettingsHandler.setTabPlacement(SwingConstants.TOP);

        break;

      case 1:
        SettingsHandler.setTabPlacement(SwingConstants.BOTTOM);

        break;

      case 2:
        SettingsHandler.setTabPlacement(SwingConstants.LEFT);

        break;

      case 3:
        SettingsHandler.setTabPlacement(SwingConstants.RIGHT);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.setOptionsBasedOnControls (mainTabPlacementCombo) the index "
                + mainTabPlacementCombo.getSelectedIndex()
                + " is unsupported.");

        break;
    }

    switch (charTabPlacementCombo.getSelectedIndex()) {
      case 0:
        SettingsHandler.setChaTabPlacement(SwingConstants.TOP);

        break;

      case 1:
        SettingsHandler.setChaTabPlacement(SwingConstants.BOTTOM);

        break;

      case 2:
        SettingsHandler.setChaTabPlacement(SwingConstants.LEFT);

        break;

      case 3:
        SettingsHandler.setChaTabPlacement(SwingConstants.RIGHT);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.setOptionsBasedOnControls (charTabPlacementCombo) the index "
                + charTabPlacementCombo.getSelectedIndex()
                + " is unsupported.");

        break;
    }

    switch (tabLabelsCombo.getSelectedIndex()) {
      case 0:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME);

        break;

      case 1:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_CLASS);

        break;

      case 2:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_RACE);

        break;

      case 3:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_RACE_CLASS);

        break;

      case 4:
        SettingsHandler.setNameDisplayStyle(Constants.DISPLAY_STYLE_NAME_FULL);

        break;

      default:
        Logging.errorPrint(
            "In PreferencesDialog.setOptionsBasedOnControls (tabLabelsCombo) the index "
                + tabLabelsCombo.getSelectedIndex()
                + " is unsupported.");

        break;
    }

    SettingsHandler.setAbilitiesShownAsATab(displayAbilitiesAsTab.isSelected());
    SettingsHandler.setExpertGUI(expertGUICheckBox.isSelected());
  }
  protected void setUpContext() throws PersistenceLayerException {
    ChooserFactory.pushChooserClassname(RandomChooser.class.getName());
    TokenRegistration.clearTokens();
    TokenRegistration.register(AUTO_LANG_TOKEN);
    TokenRegistration.register(ABILITY_VISIBLE_TOKEN);
    TokenRegistration.register(AUTO_TOKEN);
    TokenRegistration.register(CHOOSE_TOKEN);
    TokenRegistration.register(CHOOSE_LANG_TOKEN);
    TokenRegistration.register(ABILITY_MULT_TOKEN);
    TokenRegistration.register(EQUIP_TYPE_TOKEN);
    TokenRegistration.register(EQUIP_PROFICIENCY_TOKEN);
    TokenRegistration.register(LANGBONUS_PRIM);
    TokenRegistration.register(PC_QUAL);
    TokenRegistration.register(getToken());
    TokenRegistration.register(plugin.bonustokens.Feat.class);

    directAbilityFacet = FacetLibrary.getFacet(DirectAbilityFacet.class);
    activeEqModFacet = FacetLibrary.getFacet(ActiveEqModFacet.class);
    alignmentFacet = FacetLibrary.getFacet(AlignmentFacet.class);
    bioSetFacet = FacetLibrary.getFacet(BioSetFacet.class);
    checkFacet = FacetLibrary.getFacet(CheckFacet.class);
    classFacet = FacetLibrary.getFacet(ClassFacet.class);
    classLevelFacet = FacetLibrary.getFacet(ClassLevelFacet.class);
    companionModFacet = FacetLibrary.getFacet(CompanionModFacet.class);
    deityFacet = FacetLibrary.getFacet(DeityFacet.class);
    domainFacet = FacetLibrary.getFacet(DomainFacet.class);
    expandedCampaignFacet = FacetLibrary.getFacet(ExpandedCampaignFacet.class);
    languageFacet = FacetLibrary.getFacet(LanguageFacet.class);
    raceFacet = FacetLibrary.getFacet(RaceInputFacet.class);
    sizeFacet = FacetLibrary.getFacet(SizeFacet.class);
    skillFacet = FacetLibrary.getFacet(SkillFacet.class);
    statFacet = FacetLibrary.getFacet(StatFacet.class);
    templateInputFacet = FacetLibrary.getFacet(TemplateInputFacet.class);
    templateConsolidationFacet = FacetLibrary.getFacet(TemplateFacet.class);
    weaponProfModelFacet = FacetLibrary.getFacet(WeaponProfModelFacet.class);

    Globals.createEmptyRace();
    Globals.setUseGUI(false);
    Globals.emptyLists();
    GameMode gamemode = SettingsHandler.getGame();
    gamemode.clearLoadContext();

    str = BuildUtilities.createStat("Strength", "STR");
    str.put(VariableKey.getConstant("LOADSCORE"), FormulaFactory.getFormulaFor("STRSCORE"));
    str.put(VariableKey.getConstant("OFFHANDLIGHTBONUS"), FormulaFactory.getFormulaFor(2));
    dex = BuildUtilities.createStat("Dexterity", "DEX");
    PCStat con = BuildUtilities.createStat("Constitution", "CON");
    intel = BuildUtilities.createStat("Intelligence", "INT");
    wis = BuildUtilities.createStat("Wisdom", "WIS");
    cha = BuildUtilities.createStat("Charisma", "CHA");

    AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
    lg = BuildUtilities.createAlignment("Lawful Good", "LG");
    ref.importObject(lg);
    ln = BuildUtilities.createAlignment("Lawful Neutral", "LN");
    ref.importObject(ln);
    le = BuildUtilities.createAlignment("Lawful Evil", "LE");
    ref.importObject(le);
    ng = BuildUtilities.createAlignment("Neutral Good", "NG");
    ref.importObject(ng);
    tn = BuildUtilities.createAlignment("True Neutral", "TN");
    ref.importObject(tn);
    ne = BuildUtilities.createAlignment("Neutral Evil", "NE");
    ref.importObject(ne);
    cg = BuildUtilities.createAlignment("Chaotic Good", "CG");
    ref.importObject(cg);
    cn = BuildUtilities.createAlignment("Chaotic Neutral", "CN");
    ref.importObject(cn);
    ce = BuildUtilities.createAlignment("Chaotic Evil", "CE");
    ref.importObject(ce);
    ref.importObject(BuildUtilities.createAlignment("None", "NONE"));
    ref.importObject(BuildUtilities.createAlignment("Deity's", "Deity"));

    gamemode.setBonusFeatLevels("3|3");

    SettingsHandler.setGame("3.5");

    ref.importObject(str);
    ref.importObject(dex);
    ref.importObject(con);
    ref.importObject(intel);
    ref.importObject(wis);
    ref.importObject(cha);

    fine = BuildUtilities.createSize("Fine");
    diminutive = BuildUtilities.createSize("Diminutive");
    tiny = BuildUtilities.createSize("Tiny");
    small = BuildUtilities.createSize("Small");
    medium = BuildUtilities.createSize("Medium");
    medium.put(ObjectKey.IS_DEFAULT_SIZE, Boolean.TRUE);
    large = BuildUtilities.createSize("Large");
    huge = BuildUtilities.createSize("Huge");
    gargantuan = BuildUtilities.createSize("Gargantuan");
    colossal = BuildUtilities.createSize("Colossal");

    context = Globals.getContext();
    create(Language.class, "Common");
    BuildUtilities.createFact(context, "ClassType", PCClass.class);
    FactDefinition<?, String> fd = BuildUtilities.createFact(context, "SpellType", PCClass.class);
    fd.setSelectable(true);
    context.getReferenceContext().importObject(AbilityCategory.FEAT);
    SourceFileLoader.createLangBonusObject(Globals.getContext());
  }
Ejemplo n.º 29
0
 /**
  * Gets the name of the data directory for Plugin object
  *
  * @return The data directory name
  */
 public File getDataDirectory() {
   File dataDir = new File(SettingsHandler.getGmgenPluginDir(), getPluginName());
   return dataDir;
 }
Ejemplo n.º 30
0
 @Override
 public int getPriority() {
   return SettingsHandler.getGMGenOption(OPTION_NAME_LOADORDER, 1000);
 }