コード例 #1
0
ファイル: PCClass.java プロジェクト: grimreaper/pcgen
 /**
  * Add the bonus to the character's feat pool that is granted by the class. NB: LEVELSPERFEAT is
  * now handled via PLayerCHaracter.getNumFeatsFromLevels() rather than bonuses. Only the standard
  * feat progression for the gamemode is handled here.
  *
  * @param aPC The character to bonus.
  */
 void addFeatPoolBonus(final PlayerCharacter aPC) {
   Integer mLevPerFeat = get(IntegerKey.LEVELS_PER_FEAT);
   int startLevel;
   int rangeLevel;
   int divisor;
   if (mLevPerFeat == null) {
     String aString = Globals.getBonusFeatString();
     StringTokenizer aTok = new StringTokenizer(aString, "|", false);
     startLevel = Integer.parseInt(aTok.nextToken());
     rangeLevel = Integer.parseInt(aTok.nextToken());
     divisor = rangeLevel;
     if (divisor > 0) {
       StringBuilder aBuf = new StringBuilder("FEAT|PCPOOL|").append("max(CL");
       // Make sure we only take off the startlevel value once
       if (this == aPC.getClassKeyed(aPC.getLevelInfoClassKeyName(0))) {
         aBuf.append("-").append(startLevel);
         aBuf.append("+").append(rangeLevel);
       }
       aBuf.append(",0)/").append(divisor);
       //						Logging.debugPrint("Feat bonus for " + this + " is "
       //							+ aBuf.toString());
       BonusObj bon = Bonus.newBonus(Globals.getContext(), aBuf.toString());
       aPC.addBonus(bon, this);
     }
   }
 }
コード例 #2
0
ファイル: BioSet.java プロジェクト: kidaa/pcgen
  private void generateAge(
      final int ageCategory, final boolean useClassOnly, final PlayerCharacter pc) {
    // Can't find a base age for the category,
    // then there's nothing to do
    final String age =
        getTokenNumberInMaps(
            "BASEAGE",
            ageCategory,
            pc.getDisplay().getRegionString(),
            pc.getRace().getKeyName().trim());

    if (age == null) {
      return;
    }

    // First check for class age modification information
    final int baseAge = Integer.parseInt(age);
    int ageAdd = -1;

    String aClass =
        getTokenNumberInMaps(
            "CLASS",
            ageCategory,
            pc.getDisplay().getRegionString(),
            pc.getRace().getKeyName().trim());

    if (aClass != null && !aClass.equals("0")) {
      // aClass looks like:
      // Barbarian,Rogue,Sorcerer[BASEAGEADD:3d6]|Bard,Fighter,Paladin,Ranger[BASEAGEADD:1d6]
      // So first, get the BASEAGEADD
      final StringTokenizer aTok = new StringTokenizer(aClass, "|");

      while (aTok.hasMoreTokens()) {
        // String looks like:
        // Barbarian,Rogue,Sorcerer[BASEAGEADD:3d6]
        String aString = aTok.nextToken();

        final int start = aString.indexOf("[");
        final int end = aString.indexOf("]");

        // should be BASEAGEADD:xdy
        String dieString = aString.substring(start + 1, end);

        if (dieString.startsWith("BASEAGEADD:")) {
          dieString = dieString.substring(11);
        }

        // Remove the dieString
        aString = aString.substring(0, start);

        final StringTokenizer bTok = new StringTokenizer(aString, ",");

        while (bTok.hasMoreTokens() && (ageAdd < 0)) {
          final String tClass = bTok.nextToken();

          if (pc.getClassKeyed(tClass) != null) {
            ageAdd = RollingMethods.roll(dieString);
          }
        }
      }
    }

    // If there was no class age modification,
    // then generate a number based on the .LST
    if ((ageAdd < 0) && !useClassOnly) {
      aClass =
          getTokenNumberInMaps(
              "AGEDIEROLL",
              ageCategory,
              pc.getDisplay().getRegionString(),
              pc.getRace().getKeyName().trim());

      if (aClass != null) {
        ageAdd = RollingMethods.roll(aClass);
      }
    }

    if ((ageAdd >= 0) && (baseAge > 0)) {
      final String maxage =
          getTokenNumberInMaps(
              "MAXAGE",
              ageCategory,
              pc.getDisplay().getRegionString(),
              pc.getRace().getKeyName().trim());
      if (maxage != null) {
        final int maxAge = Integer.parseInt(maxage);
        if (baseAge + ageAdd > maxAge) {
          ageAdd = maxAge - baseAge;
        }
      }
      pc.setAge(baseAge + ageAdd);
    }
  }