示例#1
0
  /**
   * Get the unarmed Damage for this class at the given level.
   *
   * @param aLevel the given level.
   * @param aPC the PC with the level.
   * @param adjustForPCSize whether to adjust the result for the PC's size.
   * @return the unarmed damage string
   */
  String getUDamForEffLevel(int aLevel, final PlayerCharacter aPC, boolean adjustForPCSize) {
    int pcSize = adjustForPCSize ? aPC.sizeInt() : aPC.getDisplay().racialSizeInt();

    //
    // Check "Unarmed Strike", then default to "1d3"
    //
    String aDamage;

    AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
    final Equipment eq =
        ref.silentlyGetConstructedCDOMObject(Equipment.class, "KEY_Unarmed Strike");

    if (eq != null) {
      aDamage = eq.getDamage(aPC);
    } else {
      aDamage = "1d3";
    }

    // resize the damage as if it were a weapon
    if (adjustForPCSize) {
      int defSize = SizeUtilities.getDefaultSizeAdjustment().get(IntegerKey.SIZEORDER);
      aDamage = Globals.adjustDamage(aDamage, defSize, pcSize);
    }

    //
    // Check the UDAM list for monk-like damage
    //
    List<CDOMObject> classObjects = new ArrayList<>();
    // Negative increment to start at highest level until an UDAM is found
    for (int i = aLevel; i >= 1; i--) {
      classObjects.add(aPC.getActiveClassLevel(this, i));
    }
    classObjects.add(this);
    for (CDOMObject cdo : classObjects) {
      List<String> udam = cdo.getListFor(ListKey.UNARMED_DAMAGE);
      if (udam != null) {
        if (udam.size() == 1) {
          aDamage = udam.get(0);
        } else {
          aDamage = udam.get(pcSize);
        }
        break;
      }
    }
    return aDamage;
  }
 /**
  * Returns the unarmed damage String for the Race of the Player Character identified by the given
  * CharID.
  *
  * @param id The CharID identifying the Player Character
  * @return The unarmed damage String for the Race of the Player Character identified by the given
  *     CharID
  */
 public String getUDamForRace(CharID id) {
   Race race = raceFacet.get(id);
   int iSize =
       formulaResolvingFacet
           .resolve(id, race.getSafe(FormulaKey.SIZE), race.getQualifiedKey())
           .intValue();
   SizeAdjustment defAdj = SizeUtilities.getDefaultSizeAdjustment();
   SizeAdjustment sizAdj =
       Globals.getContext()
           .getReferenceContext()
           .getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER)
           .get(iSize);
   if (sizAdj != null) {
     return Globals.adjustDamage("1d3", defAdj, sizAdj);
   }
   return "1d3";
 }