(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source)
| 44 | { |
| 45 | |
| 46 | @SuppressWarnings("unused") |
| 47 | @Override |
| 48 | public int passes(final Prerequisite prereq, final PlayerCharacter character, CDOMObject source) |
| 49 | { |
| 50 | CharacterDisplay display = character.getDisplay(); |
| 51 | final int requiredRanks = Integer.parseInt(prereq.getOperand()); |
| 52 | // Compute the skill name from the Prerequisite |
| 53 | String requiredSkillKey = prereq.getKey().toUpperCase(); |
| 54 | if (prereq.getSubKey() != null) |
| 55 | { |
| 56 | requiredSkillKey += " (" + prereq.getSubKey().toUpperCase() + ')'; //$NON-NLS-1$ |
| 57 | } |
| 58 | final boolean isType = |
| 59 | (requiredSkillKey.startsWith("TYPE.") |
| 60 | || requiredSkillKey.startsWith("TYPE=")); //$NON-NLS-1$ //$NON-NLS-2$ |
| 61 | if (isType) |
| 62 | { |
| 63 | requiredSkillKey = requiredSkillKey.substring(5); |
| 64 | } |
| 65 | final String skillKey = requiredSkillKey; |
| 66 | // Now locate all instances of this skillname and test them |
| 67 | final int percentageSignPosition = skillKey.lastIndexOf('%'); |
| 68 | HashMap<Skill, Set<Skill>> serveAsSkills = new HashMap<>(); |
| 69 | Set<Skill> imitators = new HashSet<>(); |
| 70 | this.getImitators(serveAsSkills, imitators, display); |
| 71 | int runningTotal = 0; |
| 72 | boolean foundMatch = false; |
| 73 | boolean foundSkill = false; |
| 74 | for (Skill aSkill : display.getSkillSet()) |
| 75 | { |
| 76 | final String aSkillKey = aSkill.getKeyName().toUpperCase(); |
| 77 | if (isType) |
| 78 | { |
| 79 | if (percentageSignPosition >= 0) |
| 80 | { |
| 81 | foundMatch = matchesTypeWildCard(skillKey, percentageSignPosition, foundSkill, aSkill); |
| 82 | foundSkill = foundMatch; |
| 83 | runningTotal = getRunningTotal(aSkill, character, prereq, foundMatch, runningTotal, requiredRanks); |
| 84 | } |
| 85 | else if (aSkill.isType(skillKey)) |
| 86 | { |
| 87 | foundMatch = true; |
| 88 | foundSkill = true; |
| 89 | runningTotal = getRunningTotal(aSkill, character, prereq, true, runningTotal, requiredRanks); |
| 90 | } |
| 91 | // If there wasn't a match, then check other skills of the type |
| 92 | if (runningTotal == 0) |
| 93 | { |
| 94 | foundMatch = false; |
| 95 | } |
| 96 | } |
| 97 | else if (aSkillKey.equals(skillKey) || ((percentageSignPosition >= 0) |
| 98 | && aSkillKey.startsWith(skillKey.substring(0, percentageSignPosition)))) |
| 99 | { |
| 100 | foundMatch = true; |
| 101 | foundSkill = true; |
| 102 | runningTotal = getRunningTotal(aSkill, character, prereq, true, runningTotal, requiredRanks); |
| 103 | } |
nothing calls this directly
no test coverage detected