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

Method evaluateIIFChildren

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

Helper method to evaluate the results of a IIF child node @param children The list of children for the IIF node @param output The output to write to (filling in the character sheet template) @param aPC THe PC to output

(final List<?> children, final BufferedWriter output, final PlayerCharacter aPC)

Source from the content-addressed store, hash-verified

745 * @param aPC THe PC to output
746 */
747 private void evaluateIIFChildren(final List<?> children, final BufferedWriter output, final PlayerCharacter aPC)
748 {
749 for (Object aChild : children)
750 {
751 if (aChild instanceof final FORNode nextFor)
752 {
753 // If the child is a FORNode then put it in the loopVariables map as
754 // a key with a corresponding value of 0
755 loopVariables.put(nextFor.var(), 0);
756 existsOnly = nextFor.exists();
757
758 String minString = nextFor.min();
759 String maxString = nextFor.max();
760 String stepString = nextFor.step();
761
762 // Go through the list of objects in the loopVariables and loopParameters
763 // sets and set the values in place of keys for min, max and step
764 minString = replaceVariables(minString, loopParameters);
765 minString = replaceVariables(minString, loopVariables);
766 maxString = replaceVariables(maxString, loopParameters);
767 maxString = replaceVariables(maxString, loopVariables);
768 stepString = replaceVariables(stepString, loopParameters);
769 stepString = replaceVariables(stepString, loopVariables);
770
771 int minValue = getVarValue(minString, aPC);
772 int maxValue = getVarValue(maxString, aPC);
773 int stepValue = getVarValue(stepString, aPC);
774 String var = nextFor.var();
775 loopParameters.put(var + "!MIN", minValue);
776 loopParameters.put(var + "!MAX", maxValue);
777 loopParameters.put(var + "!STEP", stepValue);
778
779 loopFOR(nextFor, minValue, maxValue, stepValue, output, aPC);
780 loopParameters.remove(var + "!MIN");
781 loopParameters.remove(var + "!MAX");
782 loopParameters.remove(var + "!STEP");
783
784 existsOnly = nextFor.exists();
785 loopVariables.remove(nextFor.var());
786 }
787 // If child is an IIFNode, then evaluate that
788 else if (aChild instanceof IIFNode)
789 {
790 evaluateIIF((IIFNode) aChild, output, aPC);
791 }
792 // Else it's something to be processed
793 else
794 {
795 String lineString = (String) aChild;
796 lineString = replaceVariables(lineString, loopParameters);
797 lineString = replaceVariables(lineString, loopVariables);
798
799 replaceLine(lineString, output, aPC);
800
801 // Each time we replace a line that is part of an IIF statement
802 // we output a newline if we are allowed to write and the
803 // whitespace is not controlled by the OS author
804 if (canWrite && !manualWhitespace)

Callers 1

evaluateIIFMethod · 0.95

Calls 13

replaceVariablesMethod · 0.95
getVarValueMethod · 0.95
loopFORMethod · 0.95
evaluateIIFMethod · 0.95
replaceLineMethod · 0.95
newLineMethod · 0.95
varMethod · 0.80
putMethod · 0.65
removeMethod · 0.65
existsMethod · 0.45
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected