Runs count 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 that the count command will process @throws ParseException
(final Stack inStack)
| 63 | * @throws ParseException |
| 64 | */ |
| 65 | @Override |
| 66 | @SuppressWarnings("unchecked") |
| 67 | //Uses JEP, which doesn't use generics |
| 68 | public void run(final Stack inStack) throws ParseException |
| 69 | { |
| 70 | // Grab the character under scrutiny |
| 71 | final PlayerCharacter pc = getPC(); |
| 72 | |
| 73 | if (pc == null) |
| 74 | { |
| 75 | throw new ParseException("Invalid parent (no PC): " + parent.getClass().getName()); |
| 76 | } |
| 77 | |
| 78 | // check the stack |
| 79 | checkStack(inStack); |
| 80 | |
| 81 | if (1 <= curNumberOfParameters) |
| 82 | { |
| 83 | // move all but the first parameter from the stack into and array of Objects |
| 84 | final Object[] params = paramStackToArray(inStack, curNumberOfParameters - 1); |
| 85 | |
| 86 | // retrieve the first Object, this should be a String which will map directly to |
| 87 | // a JepCountEnum, this specifies the type of count to perform |
| 88 | final Object toCount = inStack.pop(); |
| 89 | |
| 90 | if (toCount instanceof String) |
| 91 | { |
| 92 | final JepCountType countEnum = JepCountType.valueOf((String) toCount); |
| 93 | if (countEnum == null) |
| 94 | { |
| 95 | Logging.errorPrint("Unable to find count type: " + toCount); |
| 96 | } |
| 97 | |
| 98 | // Count the requested object type. |
| 99 | final Double result = (Double) countEnum.count(pc, params); |
| 100 | |
| 101 | inStack.push(result); |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | throw new ParseException("Invalid parameter type"); |
| 106 | } |
| 107 | } |
| 108 | else |
| 109 | { |
| 110 | throw new ParseException("missing parameter, nothing to count"); |
| 111 | } |
| 112 | } |
| 113 | } |
nothing calls this directly
no test coverage detected