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

Method calcEqModCost

code/src/java/pcgen/core/Equipment.java:883–895  ·  view source on GitHub ↗

Calculates the value of a formula. Does some preprocesing for variables that cannot be properly evaluated with just the equipment context that is held by the variable processor. @param aPC The character we are calculating the cost for. @param costFormula The formula to be evaluated. @param primaryHe

(final PlayerCharacter aPC, String costFormula, boolean primaryHead)

Source from the content-addressed store, hash-verified

881 * @return The value of the formula
882 */
883 private String calcEqModCost(final PlayerCharacter aPC, String costFormula, boolean primaryHead)
884 {
885 Pattern pat = Pattern.compile("BASECOST");
886 Matcher mat = pat.matcher(costFormula);
887
888 // make string (BASECOST/X) which will be substituted into
889 // the cost string which is then converted to a number
890 String sB = "(BASECOST/" + getSafe(IntegerKey.BASE_QUANTITY)
891 + ")";
892 String s = mat.replaceAll(sB);
893
894 return getVariableValue(s, "", primaryHead, aPC).toString();
895 }
896
897 /**
898 * Set cost mod

Callers 1

Calls 4

getVariableValueMethod · 0.95
getSafeMethod · 0.80
toStringMethod · 0.65
replaceAllMethod · 0.45

Tested by

no test coverage detected