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

Method run

code/src/java/plugin/jepcommands/MasterVarCommand.java:61–106  ·  view source on GitHub ↗

Runs mastervar on the inStack. The parameter is popped off the inStack, and the variable's value is pushed back to the top of inStack. @param inStack the jep stack @throws ParseException

(final Stack inStack)

Source from the content-addressed store, hash-verified

59 * @throws ParseException
60 */
61 @SuppressWarnings("unchecked") //Uses JEP, which doesn't use generics
62 @Override
63 public void run(final Stack inStack) throws ParseException
64 {
65 // check the stack
66 checkStack(inStack);
67
68 // get the parameter from the stack
69 final Object param1;
70
71 if (curNumberOfParameters == 1)
72 {
73 param1 = inStack.pop();
74 }
75 else
76 {
77 throw new ParseException("Invalid parameter count");
78 }
79
80 if (param1 instanceof String)
81 {
82 Float result;
83 PlayerCharacter pc = getPC();
84 if (pc == null)
85 {
86 throw new ParseException("Invalid parent for function");
87 }
88 PlayerCharacter master = pc.getMasterPC();
89 if (master == null)
90 {
91 throw new ParseException("Invalid: PC had no master");
92 }
93 result = master.getVariableValue((String) param1, variableSource);
94
95 if (result == null)
96 {
97 throw new ParseException("Error retreiving variable:" + param1);
98 }
99
100 inStack.push(result.doubleValue());
101 }
102 else
103 {
104 throw new ParseException("Invalid parameter type");
105 }
106 }
107
108 /**
109 * Get the PC that will be used to determine the master

Callers

nothing calls this directly

Calls 6

getPCMethod · 0.95
getMasterPCMethod · 0.95
getVariableValueMethod · 0.95
popMethod · 0.80
pushMethod · 0.80
doubleValueMethod · 0.80

Tested by

no test coverage detected