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

Method run

code/src/java/plugin/jepcommands/SkillInfoCommand.java:52–135  ·  view source on GitHub ↗

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

50 * @throws ParseException
51 */
52 @SuppressWarnings("unchecked") //Uses JEP, which doesn't use generics
53 @Override
54 public void run(final Stack inStack) throws ParseException
55 {
56 // check the stack
57 checkStack(inStack);
58
59 // get the parameters from the stack
60 //
61 // have to do this in reverse order...this is a stack afterall
62 //
63 final Object param2 = inStack.pop();
64 final Object param1 = inStack.pop();
65
66 if ((param1 instanceof String) && (param2 instanceof String))
67 {
68 PlayerCharacter pc = null;
69
70 if (parent instanceof VariableProcessor)
71 {
72 pc = ((VariableProcessor) parent).getPc();
73 }
74 else if (parent instanceof PlayerCharacter)
75 {
76 pc = (PlayerCharacter) parent;
77 }
78 if (pc == null)
79 {
80 throw new ParseException("Invalid parent (no PC): " + parent.getClass().getName());
81 }
82
83 Skill aSkill = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Skill.class,
84 param2.toString());
85
86 Object result;
87 if (aSkill != null && pc.getDisplay().hasSkill(aSkill))
88 {
89 if ("modifier".equalsIgnoreCase((String) param1))
90 {
91 result =
92 (double) SkillModifier.modifier(aSkill, pc); // aSkill.modifier() returns Integer
93 }
94 else if ("rank".equalsIgnoreCase((String) param1))
95 {
96 result = pc.getDisplay().getRank(aSkill).doubleValue(); // aSkill.getRank() returns Float
97 }
98 else if ("total".equalsIgnoreCase((String) param1))
99 {
100 result = (double) SkillRankControl.getTotalRank(pc, aSkill).intValue()
101 + SkillModifier.modifier(aSkill, pc);
102 }
103 else if ("totalrank".equalsIgnoreCase((String) param1))
104 {
105 result =
106 SkillRankControl.getTotalRank(pc, aSkill).doubleValue(); // aSkill.getTotalRank() returns Float
107 }
108 else if ("stat".equalsIgnoreCase((String) param1))
109 {

Callers

nothing calls this directly

Calls 15

getContextMethod · 0.95
getDisplayMethod · 0.95
modifierMethod · 0.95
getTotalRankMethod · 0.95
getStatModMethod · 0.95
logMethod · 0.95
popMethod · 0.80
equalsIgnoreCaseMethod · 0.80
doubleValueMethod · 0.80
intValueMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected