Helper method to evaluate a IIF token @param node The IIFNode to evaluate @param output The output to write to (character sheet template) @param aPC The PC we are outputting
(final IIFNode node, final BufferedWriter output, final PlayerCharacter aPC)
| 719 | * @param aPC The PC we are outputting |
| 720 | */ |
| 721 | private void evaluateIIF(final IIFNode node, final BufferedWriter output, final PlayerCharacter aPC) |
| 722 | { |
| 723 | // Comma is a delimiter for a higher-level parser, so |
| 724 | // we'll use a semicolon and replace it with a comma for |
| 725 | // expressions like: |
| 726 | // |IIF(VAR.IF(var("COUNT[SKILLTYPE=Strength]")>0;1;0):1)| |
| 727 | final String aString = node.expr().replaceAll(Pattern.quote(";"), ","); |
| 728 | |
| 729 | // If we can evaluate the expression then evaluate its children |
| 730 | if (evaluateExpression(aString, aPC)) |
| 731 | { |
| 732 | evaluateIIFChildren(node.trueChildren(), output, aPC); |
| 733 | } |
| 734 | else |
| 735 | { |
| 736 | evaluateIIFChildren(node.falseChildren(), output, aPC); |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | /** |
| 741 | * Helper method to evaluate the results of a IIF child node |
no test coverage detected