private void generateHeightWeight(final PlayerCharacter pc) { int baseHeight = 0; int baseWeight = 0; int htAdd = 0; int wtAdd = 0; String totalWeight = null; final String htwt = getTokenNumberInMaps( "SEX", 0, pc.getDisplay().getRegionString(), pc.getRace().getKeyName().trim()); if (htwt == null) { return; } final StringTokenizer genderTok = new StringTokenizer(htwt, "[]", false); while (genderTok.hasMoreTokens()) { if (genderTok.nextToken().equals(pc.getDisplay().getGenderObject().toString())) { final String htWtLine = genderTok.nextToken(); final StringTokenizer htwtTok = new StringTokenizer(htWtLine, "|", false); while (htwtTok.hasMoreTokens()) { final String tag = htwtTok.nextToken(); if (tag.startsWith("BASEHT:")) { baseHeight = Integer.parseInt(tag.substring(7)); } else if (tag.startsWith("BASEWT:")) { baseWeight = Integer.parseInt(tag.substring(7)); } else if (tag.startsWith("HTDIEROLL:")) { htAdd = RollingMethods.roll(tag.substring(10)); } else if (tag.startsWith("WTDIEROLL:")) { wtAdd = RollingMethods.roll(tag.substring(10)); } else if (tag.startsWith("TOTALWT:")) { totalWeight = tag.substring(8); } } if ((baseHeight != 0) && (htAdd != 0)) { pc.setHeight(baseHeight + htAdd); } if ((totalWeight != null) && (baseWeight != 0) && (wtAdd != 0)) { totalWeight = replaceString(totalWeight, "HTDIEROLL", htAdd); totalWeight = replaceString(totalWeight, "BASEWT", baseWeight); totalWeight = replaceString(totalWeight, "WTDIEROLL", wtAdd); pc.setWeight(pc.getVariableValue(totalWeight, "").intValue()); } break; } genderTok.nextToken(); // burn next token } }
/** * 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; }
private String generateBioValue(final String addKey, final PlayerCharacter pc) { final String line = getTokenNumberInMaps( addKey, 0, pc.getDisplay().getRegionString(), pc.getRace().getKeyName().trim()); final String rv; if (line != null && line.length() > 0) { final StringTokenizer aTok = new StringTokenizer(line, "|"); final List<String> aList = new ArrayList<String>(); while (aTok.hasMoreTokens()) { aList.add(aTok.nextToken()); } final int roll = RollingMethods.roll(1, aList.size()) - 1; // needs to be 0-offset rv = aList.get(roll); } else { rv = ""; } return rv; }
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); } }