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

Method run

code/src/java/plugin/jepcommands/GetVarCommand.java:45–125  ·  view source on GitHub ↗

Runs getvar 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

43 * @throws ParseException
44 */
45 @SuppressWarnings("unchecked") //Uses JEP, which doesn't use generics
46 @Override
47 public void run(final Stack inStack) throws ParseException
48 {
49 // check the stack
50 checkStack(inStack);
51
52 // get the parameter from the stack
53 final Object param1;
54 Object param2 = null;
55
56 //
57 // have to do this in reverse order...this is a stack afterall
58 //
59 if (curNumberOfParameters == 1)
60 {
61 param1 = inStack.pop();
62 }
63 else if (curNumberOfParameters == 2)
64 {
65 param2 = inStack.pop();
66 param1 = inStack.pop();
67
68 if (!(param2 instanceof Double))
69 {
70 throw new ParseException("Invalid parameter type");
71 }
72 }
73 else
74 {
75 throw new ParseException("Invalid parameter count");
76 }
77
78 if (param1 instanceof String)
79 {
80 Float result = null;
81 if (parent instanceof final PlayerCharacter character)
82 {
83 result = getVariableForCharacter(character, param1);
84 }
85 else if (parent instanceof Equipment)
86 {
87 boolean bPrimary = true;
88
89 if (param2 != null)
90 {
91 bPrimary = (((Double) param2).intValue() != 0);
92 }
93
94 result = ((Equipment) parent).getVariableValue((String) param1, "", bPrimary, null);
95 }
96 else if (parent instanceof final VariableProcessorPC vpc)
97 {
98 // check to see if this is just a variable
99 result = vpc.lookupVariable((String) param1, variableSource, null);
100 if (result == null)
101 {
102 result = vpc.getVariableValue(null, (String) param1, variableSource, 0);

Callers

nothing calls this directly

Calls 9

errorPrintMethod · 0.95
popMethod · 0.80
intValueMethod · 0.80
lookupVariableMethod · 0.80
pushMethod · 0.80
doubleValueMethod · 0.80
getVariableValueMethod · 0.65
valueOfMethod · 0.45

Tested by

no test coverage detected