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

Method doPartyForToken

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

Deal with the FOR. token, but at a party level @param PCs The PCs to export @param out The Output we are writing to @param tokenString The token string to process

(PlayerCharacter[] PCs, BufferedWriter out, String tokenString)

Source from the content-addressed store, hash-verified

3164 * @param tokenString The token string to process
3165 */
3166 private void doPartyForToken(PlayerCharacter[] PCs, BufferedWriter out, String tokenString)
3167 {
3168 PartyForParser forParser = new PartyForParser(tokenString, PCs.length);
3169
3170 int x = 0;
3171 for (int i = forParser.min(); i < forParser.max(); i++)
3172 {
3173 if (x == 0)
3174 {
3175 FileAccess.write(out, forParser.startOfLine());
3176 }
3177
3178 PlayerCharacter currPC = ((i >= 0) && (i < PCs.length)) ? PCs[i] : null;
3179
3180 String[] tokens = forParser.tokenString().split("\\\\\\\\");
3181
3182 for (String tok : tokens)
3183 {
3184 if (tok.startsWith("%."))
3185 {
3186 if (currPC != null)
3187 {
3188 replaceToken(tok.substring(2), out, currPC);
3189 }
3190 }
3191 else
3192 {
3193 FileAccess.write(out, tok);
3194 }
3195 }
3196
3197 // Note: This was changed from == to && since I can't see how
3198 // == could possibly be correct behaviour. If we were not
3199 // just printing characters that exist the loop would
3200 // terminate after printing one character.
3201 boolean breakloop = (forParser.existsOnly() && (currPC == null));
3202
3203 ++x;
3204 if (x == forParser.step() || breakloop)
3205 {
3206 x = 0;
3207 FileAccess.write(out, forParser.endOfLine());
3208
3209 if (breakloop)
3210 {
3211 break;
3212 }
3213 }
3214 }
3215 }
3216
3217 /*
3218 * ##########################################################################

Callers 1

processPipedLineMethod · 0.95

Calls 10

minMethod · 0.95
maxMethod · 0.95
writeMethod · 0.95
startOfLineMethod · 0.95
tokenStringMethod · 0.95
replaceTokenMethod · 0.95
existsOnlyMethod · 0.95
stepMethod · 0.95
endOfLineMethod · 0.95
splitMethod · 0.45

Tested by

no test coverage detected