예제 #1
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();
  }
예제 #2
0
 /** @see pcgen.output.base.OutputActor#process(pcgen.cdom.enumeration.CharID, java.lang.Object) */
 @Override
 public TemplateModel process(CharID id, CDOMObject d) throws TemplateModelException {
   String outputName = OutputNameFormatting.getOutputName(d);
   return ObjectWrapper.SIMPLE_WRAPPER.wrap(outputName);
 }
예제 #3
0
  /* (non-Javadoc)
   * @see pcgen.core.facade.SpellSupportFacade#getClassInfo(pcgen.core.facade.ClassFacade)
   */
  @Override
  public String getClassInfo(ClassFacade spellcaster) {
    if (!(spellcaster instanceof PCClass)) {
      return "";
    }
    PCClass aClass = (PCClass) spellcaster;
    SpellSupportForPCClass spellSupport = pc.getSpellSupport(aClass);
    int highestSpellLevel = spellSupport.getHighestLevelSpell(pc);

    final HtmlInfoBuilder b = new HtmlInfoBuilder();
    b.append("<table border=1><tr><td><font size=-2><b>"); // $NON-NLS-1$
    b.append(OutputNameFormatting.piString(aClass, false)).append(" ["); // $NON-NLS-1$
    b.append(
        String.valueOf(
            charDisplay.getLevel(aClass)
                + (int) pc.getTotalBonusTo("PCLEVEL", aClass.getKeyName()))); // $NON-NLS-1$
    b.append("]</b></font></td>"); // $NON-NLS-1$

    for (int i = 0; i <= highestSpellLevel; ++i) {
      b.append("<td><font size=-2><b><center>&nbsp;"); // $NON-NLS-1$
      b.append(String.valueOf(i));
      b.append("&nbsp;</b></center></font></td>"); // $NON-NLS-1$
    }

    b.append("</tr>"); // $NON-NLS-1$
    b.append("<tr><td><font size=-1><b>Cast</b></font></td>"); // $NON-NLS-1$

    for (int i = 0; i <= highestSpellLevel; ++i) {
      b.append("<td><font size=-1><center>"); // $NON-NLS-1$
      b.append(getNumCast(aClass, i, pc));
      b.append("</center></font></td>"); // $NON-NLS-1$
    }
    b.append("</tr>"); // $NON-NLS-1$

    // Making sure KnownList can be handled safely and produces the correct behaviour
    if (spellSupport.hasKnownList() || spellSupport.hasKnownSpells(pc)) {
      b.append("<tr><td><font size=-1><b>Known</b></font></td>"); // $NON-NLS-1$

      for (int i = 0; i <= highestSpellLevel; ++i) {
        final int a = spellSupport.getKnownForLevel(i, pc);
        final int bonus = spellSupport.getSpecialtyKnownForLevel(i, pc);

        b.append("<td><font size=-1><center>"); // $NON-NLS-1$
        b.append(String.valueOf(a));
        if (bonus > 0) {
          b.append('+').append(Integer.toString(bonus));
        }
        b.append("</center></font></td>"); // $NON-NLS-1$
      }
      b.append("</tr>"); // $NON-NLS-1$
    }

    b.append("<tr><td><font size=-1><b>DC</b></font></td>"); // $NON-NLS-1$

    for (int i = 0; i <= highestSpellLevel; ++i) {
      b.append("<td><font size=-1><center>"); // $NON-NLS-1$
      b.append(String.valueOf(getDC(aClass, i, pc)));
      b.append("</center></font></td>"); // $NON-NLS-1$
    }

    b.append("</tr></table>"); // $NON-NLS-1$

    b.appendI18nElement("InfoSpells.caster.type", aClass.getSpellType()); // $NON-NLS-1$
    b.appendLineBreak();
    b.appendI18nElement("InfoSpells.stat.bonus", aClass.getSpellBaseStat()); // $NON-NLS-1$

    if (pc.hasAssocs(aClass, AssociationKey.SPECIALTY) || charDisplay.hasDomains()) {
      boolean needComma = false;
      StringBuilder schoolInfo = new StringBuilder();
      String spec = pc.getAssoc(aClass, AssociationKey.SPECIALTY);
      if (spec != null) {
        schoolInfo.append(spec);
        needComma = true;
      }

      for (Domain d : charDisplay.getSortedDomainSet()) {
        if (needComma) {
          schoolInfo.append(',');
        }
        needComma = true;
        schoolInfo.append(d.getKeyName());
      }
      b.appendLineBreak();
      b.appendI18nElement("InfoSpells.school", schoolInfo.toString()); // $NON-NLS-1$
    }

    Set<String> set = new TreeSet<>();
    for (SpellProhibitor sp : aClass.getSafeListFor(ListKey.PROHIBITED_SPELLS)) {
      set.addAll(sp.getValueList());
    }

    Collection<? extends SpellProhibitor> prohibList = charDisplay.getProhibitedSchools(aClass);
    if (prohibList != null) {
      for (SpellProhibitor sp : prohibList) {
        set.addAll(sp.getValueList());
      }
    }
    if (!set.isEmpty()) {
      b.appendLineBreak();
      b.appendI18nElement(
          "InfoSpells.prohibited.school", //$NON-NLS-1$
          StringUtil.join(set, ",")); // $NON-NLS-1$
    }

    String bString = SourceFormat.getFormattedString(aClass, Globals.getSourceDisplay(), true);
    if (bString.length() > 0) {
      b.appendLineBreak();
      b.appendI18nElement("in_source", bString); // $NON-NLS-1$
    }

    return b.toString();
  }