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

Method replaceTokenForDfor

code/src/java/pcgen/io/ExportHandler.java:2522–2739  ·  view source on GitHub ↗

Helper method to deal with DFOR token, e.g. DFOR.0,(COUNT[SKILLS]+1)/2,1,COUNT[SKILLS],(COUNT[SKILLS]+1)/2, \SKILL%\ \SKILL%.TOTAL\ \SKILL%.RANK\ \SKILL%.ABILITY\ \SKILL%.MOD\, , ,0 Produces a 2 column row table of all skills. @param aStr

(String aString, BufferedWriter output, PlayerCharacter aPC)

Source from the content-addressed store, hash-verified

2520 * @param aPC PC we are exporting
2521 */
2522 private void replaceTokenForDfor(String aString, BufferedWriter output, PlayerCharacter aPC)
2523 {
2524 StringTokenizer aTok;
2525
2526 // Split after DFOR. or DFOR by the ',' delimiter
2527 if (aString.startsWith("DFOR."))
2528 {
2529 aTok = new StringTokenizer(aString.substring(5), ",", false);
2530 }
2531 else
2532 {
2533 aTok = new StringTokenizer(aString.substring(4), ",", false);
2534 }
2535
2536 int cMin = 0;
2537 int cMax = 100;
2538 int cStep = 1;
2539 int cStepLine = 1;
2540 int cStepLineMax = 0;
2541 String cString = "";
2542 String cStartLineString = "";
2543 String cEndLineString = "";
2544 boolean isDFor = false;
2545
2546 int i = 0;
2547
2548 // While there are more tokens
2549 while (aTok.hasMoreTokens())
2550 {
2551 String tokA = aTok.nextToken();
2552
2553 switch (i)
2554 {
2555 case 0 -> cMin = getVarValue(tokA, aPC);
2556 case 1 -> cMax = getVarValue(tokA, aPC);
2557 case 2 -> {
2558 cStep = getVarValue(tokA, aPC);
2559 if (aString.startsWith("DFOR."))
2560 {
2561 isDFor = true;
2562 cStepLineMax = getVarValue(aTok.nextToken(), aPC);
2563 cStepLine = getVarValue(aTok.nextToken(), aPC);
2564 }
2565 }
2566 case 3 -> cString = tokA;
2567 case 4 -> cStartLineString = tokA;
2568 case 5 -> cEndLineString = tokA;
2569 case 6 -> {
2570 existsOnly = (!"0".equals(tokA));
2571 if ("2".equals(tokA))
2572 {
2573 checkBefore = true;
2574 }
2575 }
2576 default -> Logging.errorPrint("ExportHandler.replaceTokenForDfor can't handle token number " + i
2577 + " this probably means you've passed in too many parameters.");
2578 }
2579 i++;

Callers 1

processLoopTokenMethod · 0.95

Calls 10

getVarValueMethod · 0.95
errorPrintMethod · 0.95
writeMethod · 0.95
replaceTokenMethod · 0.95
hasMoreTokensMethod · 0.80
nextTokenMethod · 0.80
parseIntMethod · 0.80
equalsMethod · 0.65
indexOfMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected