MCPcopy Create free account
hub / github.com/PCGen/pcgen / generateAge

Method generateAge

code/src/java/pcgen/core/BioSet.java:379–466  ·  view source on GitHub ↗
(final int ageCategory, final boolean useClassOnly, final PlayerCharacter pc)

Source from the content-addressed store, hash-verified

377 }
378
379 private void generateAge(final int ageCategory, final boolean useClassOnly, final PlayerCharacter pc)
380 {
381 // Can't find a base age for the category,
382 // then there's nothing to do
383 final String age = getTokenNumberInMaps("BASEAGE", ageCategory, pc.getDisplay().getRegion(),
384 pc.getRace().getKeyName().trim());
385
386 if (age == null)
387 {
388 return;
389 }
390
391 // First check for class age modification information
392 final int baseAge = Integer.parseInt(age);
393 int ageAdd = -1;
394
395 String aClass = getTokenNumberInMaps("CLASS", ageCategory, pc.getDisplay().getRegion(),
396 pc.getRace().getKeyName().trim());
397
398 if (aClass != null && !aClass.equals("0"))
399 {
400 // aClass looks like:
401 // Barbarian,Rogue,Sorcerer[BASEAGEADD:3d6]|Bard,Fighter,Paladin,Ranger[BASEAGEADD:1d6]
402 // So first, get the BASEAGEADD
403 final StringTokenizer aTok = new StringTokenizer(aClass, "|");
404
405 while (aTok.hasMoreTokens())
406 {
407 // String looks like:
408 // Barbarian,Rogue,Sorcerer[BASEAGEADD:3d6]
409 String aString = aTok.nextToken();
410
411 final int start = aString.indexOf('[');
412 final int end = aString.indexOf(']');
413
414 // should be BASEAGEADD:xdy
415 String dieString = aString.substring(start + 1, end);
416
417 if (dieString.startsWith("BASEAGEADD:"))
418 {
419 dieString = dieString.substring(11);
420 }
421
422 // Remove the dieString
423 aString = aString.substring(0, start);
424
425 final StringTokenizer bTok = new StringTokenizer(aString, ",");
426
427 while (bTok.hasMoreTokens() && (ageAdd < 0))
428 {
429 final String tClass = bTok.nextToken();
430
431 if (pc.getClassKeyed(tClass) != null)
432 {
433 ageAdd = RollingMethods.roll(dieString);
434 }
435 }
436 }

Callers 1

randomizeMethod · 0.95

Calls 15

getTokenNumberInMapsMethod · 0.95
rollMethod · 0.95
setControlledChannelMethod · 0.95
trimMethod · 0.80
parseIntMethod · 0.80
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
getKeyNameMethod · 0.65
equalsMethod · 0.65
indexOfMethod · 0.65
getCharIDMethod · 0.65
getRegionMethod · 0.45

Tested by

no test coverage detected