(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source)
| 36 | { |
| 37 | |
| 38 | @Override |
| 39 | public int passes(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source) |
| 40 | throws PrerequisiteException |
| 41 | { |
| 42 | int runningTotal = 0; |
| 43 | |
| 44 | final int number; |
| 45 | try |
| 46 | { |
| 47 | number = Integer.parseInt(prereq.getOperand()); |
| 48 | } |
| 49 | catch (NumberFormatException exceptn) |
| 50 | { |
| 51 | throw new PrerequisiteException( |
| 52 | LanguageBundle.getFormattedString("PreFeat.error", prereq.toString()), exceptn); //$NON-NLS-1$ |
| 53 | } |
| 54 | |
| 55 | CharacterDisplay display = character.getDisplay(); |
| 56 | if (display.hasEquipment()) |
| 57 | { |
| 58 | |
| 59 | String targetEquip = prereq.getKey(); |
| 60 | for (Equipment eq : display.getEquippedEquipmentSet()) |
| 61 | { |
| 62 | if (targetEquip.startsWith("WIELDCATEGORY=") || targetEquip.startsWith("WIELDCATEGORY.")) |
| 63 | { |
| 64 | final WieldCategory wCat = eq.getEffectiveWieldCategory(character); |
| 65 | if ((wCat != null) && wCat.getKeyName().equalsIgnoreCase(targetEquip.substring(14))) |
| 66 | { |
| 67 | ++runningTotal; |
| 68 | break; |
| 69 | } |
| 70 | } |
| 71 | else if (targetEquip.startsWith("TYPE=") || targetEquip.startsWith("TYPE.")) //$NON-NLS-1$ //$NON-NLS-2$ |
| 72 | { |
| 73 | StringTokenizer tok = new StringTokenizer(targetEquip.substring(5).toUpperCase(), "."); |
| 74 | boolean match = false; |
| 75 | if (tok.hasMoreTokens()) |
| 76 | { |
| 77 | match = true; |
| 78 | } |
| 79 | // |
| 80 | // Must match all listed types in order to qualify |
| 81 | // |
| 82 | while (tok.hasMoreTokens()) |
| 83 | { |
| 84 | final String type = tok.nextToken(); |
| 85 | if (!eq.isType(type)) |
| 86 | { |
| 87 | match = false; |
| 88 | break; |
| 89 | } |
| 90 | } |
| 91 | if (match) |
| 92 | { |
| 93 | ++runningTotal; |
| 94 | break; |
| 95 | } |
nothing calls this directly
no test coverage detected