| 183 | * is this ever out of sync or can this method be removed/made private?? |
| 184 | */ |
| 185 | public double getBonusTo(final String argType, final String argMname, final int asLevel, final PlayerCharacter aPC) |
| 186 | { |
| 187 | double i = 0; |
| 188 | |
| 189 | List<BonusObj> rawBonusList = getRawBonusList(aPC); |
| 190 | |
| 191 | for (int lvl = 1; lvl < asLevel; lvl++) |
| 192 | { |
| 193 | rawBonusList.addAll(aPC.getActiveClassLevel(this, lvl).getRawBonusList(aPC)); |
| 194 | } |
| 195 | if ((asLevel == 0) || rawBonusList.isEmpty()) |
| 196 | { |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | final String type = argType.toUpperCase(); |
| 201 | final String mname = argMname.toUpperCase(); |
| 202 | |
| 203 | for (final BonusObj bonus : rawBonusList) |
| 204 | { |
| 205 | final StringTokenizer breakOnPipes = |
| 206 | new StringTokenizer(bonus.toString().toUpperCase(), Constants.PIPE, false); |
| 207 | final String theType = breakOnPipes.nextToken(); |
| 208 | |
| 209 | if (!theType.equals(type)) |
| 210 | { |
| 211 | continue; |
| 212 | } |
| 213 | |
| 214 | final String str = breakOnPipes.nextToken(); |
| 215 | final StringTokenizer breakOnCommas = new StringTokenizer(str, Constants.COMMA, false); |
| 216 | |
| 217 | while (breakOnCommas.hasMoreTokens()) |
| 218 | { |
| 219 | final String theName = breakOnCommas.nextToken(); |
| 220 | |
| 221 | if (theName.equals(mname)) |
| 222 | { |
| 223 | final String aString = breakOnPipes.nextToken(); |
| 224 | final List<Prerequisite> localPreReqList = new ArrayList<>(); |
| 225 | if (bonus.hasPrerequisites()) |
| 226 | { |
| 227 | localPreReqList.addAll(bonus.getPrerequisiteList()); |
| 228 | } |
| 229 | |
| 230 | // TODO: This code should be removed after the 5.8 release |
| 231 | // as the prereqs are processed by the bonus loading code. |
| 232 | while (breakOnPipes.hasMoreTokens()) |
| 233 | { |
| 234 | final String bString = breakOnPipes.nextToken(); |
| 235 | |
| 236 | if (PreParserFactory.isPreReqString(bString)) |
| 237 | { |
| 238 | Logging.debugPrint( |
| 239 | "Why is this prerequisite '" + bString + "' parsed in '" //$NON-NLS-1$//$NON-NLS-2$ |
| 240 | + getClass().getName() |
| 241 | + ".getBonusTo(String,String,int)' rather than in the persistence layer?"); //$NON-NLS-1$ |
| 242 | try |