MCPcopy Index your code
hub / github.com/PCGen/pcgen / parseToken

Method parseToken

code/src/java/plugin/bonustokens/Save.java:32–79  ·  view source on GitHub ↗
(LoadContext context, final String argToken)

Source from the content-addressed store, hash-verified

30public final class Save extends BonusObj
31{
32 @Override
33 protected boolean parseToken(LoadContext context, final String argToken)
34 {
35 if (ControlUtilities.hasControlToken(context, CControl.TOTALSAVE))
36 {
37 Logging.errorPrint("BONUS:SAVE is disabled when TOTALSAVE code control is used: " + argToken, context);
38 return false;
39 }
40 boolean isBase = false;
41 final String token;
42
43 if (argToken.startsWith("BASE."))
44 {
45 token = argToken.substring(Constants.SUBSTRING_LENGTH_FIVE);
46 isBase = true;
47 }
48 else
49 {
50 token = argToken;
51 }
52
53 if ("%LIST".equals(token))
54 {
55 // Special case of: BONUS:SAVE|%LIST|x
56 addBonusInfo(listCheck);
57 }
58 else if ("ALL".equals(token))
59 {
60 // Special case of: BONUS:SAVE|ALL|x
61 /*
62 * TODO Prohibit use in Game Mode, or alternately, all areas where
63 * SAVE are established need to test both SAVE|Blah and
64 * SAVE|ALL
65 */
66 for (PCCheck check : context.getReferenceContext().getConstructedCDOMObjects(PCCheck.class))
67 {
68 addBonusInfo(new CheckInfo(CDOMDirectSingleRef.getRef(check), isBase));
69 }
70 }
71 else
72 {
73 CDOMReference<PCCheck> aCheck = context.getReferenceContext().getCDOMReference(PCCheck.class, token);
74 //Invalid name is caught by Unconstructed Reference system
75 addBonusInfo(new CheckInfo(aCheck, isBase));
76 }
77
78 return true;
79 }
80
81 /**
82 * Unparse the bonus token.

Callers

nothing calls this directly

Calls 8

hasControlTokenMethod · 0.95
errorPrintMethod · 0.95
getRefMethod · 0.95
addBonusInfoMethod · 0.80
getCDOMReferenceMethod · 0.80
equalsMethod · 0.65
getReferenceContextMethod · 0.65

Tested by

no test coverage detected