Tack on the cost of the magical enhancement(s). @param iPlus the Pluses of the primary head @param altPlus the Pluses of the secondary head @return cost from pluses
(final int iPlus, final int altPlus)
| 3949 | * @return cost from pluses |
| 3950 | */ |
| 3951 | private BigDecimal getCostFromPluses(final int iPlus, final int altPlus) |
| 3952 | { |
| 3953 | |
| 3954 | if (((iPlus != 0) || (altPlus != 0)) && (JEPResourceChecker.getMissingResourceCount() == 0)) |
| 3955 | { |
| 3956 | PJEP myParser = null; |
| 3957 | try |
| 3958 | { |
| 3959 | myParser = PjepPool.getInstance().aquire(); |
| 3960 | myParser.addVariable("PLUS", iPlus); |
| 3961 | myParser.addVariable("ALTPLUS", altPlus); |
| 3962 | myParser.addVariable("BASECOST", getSafe(ObjectKey.COST).doubleValue()); |
| 3963 | |
| 3964 | if (isAmmunition()) |
| 3965 | { |
| 3966 | myParser.addVariable("BASEQTY", getSafe(IntegerKey.BASE_QUANTITY)); |
| 3967 | } |
| 3968 | |
| 3969 | // Look for an expression for all of this item's types |
| 3970 | // If there is more than 1, use the most expensive. |
| 3971 | String costExpr; |
| 3972 | BigDecimal maxCost = null; |
| 3973 | final List<String> itemTypes = typeList(); |
| 3974 | |
| 3975 | for (String typeMatched : itemTypes) |
| 3976 | { |
| 3977 | costExpr = SettingsHandler.getGameAsProperty().get().getPlusCalculation(Type.getConstant(typeMatched)); |
| 3978 | |
| 3979 | if (costExpr != null) |
| 3980 | { |
| 3981 | final BigDecimal thisCost = evaluateCost(myParser, costExpr); |
| 3982 | |
| 3983 | if ((maxCost == null) || (thisCost.compareTo(maxCost) > 1)) |
| 3984 | { |
| 3985 | maxCost = thisCost; |
| 3986 | } |
| 3987 | } |
| 3988 | } |
| 3989 | |
| 3990 | if (maxCost != null) |
| 3991 | { |
| 3992 | return maxCost; |
| 3993 | } |
| 3994 | |
| 3995 | // |
| 3996 | // No cost formula found, check for catch-all definition |
| 3997 | // |
| 3998 | costExpr = SettingsHandler.getGameAsProperty().get().getPlusCalculation(Type.ANY); |
| 3999 | |
| 4000 | if (costExpr != null) |
| 4001 | { |
| 4002 | return evaluateCost(myParser, costExpr); |
| 4003 | } |
| 4004 | } |
| 4005 | finally |
| 4006 | { |
| 4007 | PjepPool.getInstance().release(myParser); |
| 4008 | } |
no test coverage detected