Select the target skill based on the supplied critieria. Searches through the characters skill list selecting those that have the type of details.properties[0] and then uses the index in details.skillId to select the skill. @param tokenSource The token being processed. Used for error reporting. @pa
(String tokenSource, PlayerCharacter pc, SkillDetails details, ExportHandler eh)
| 76 | * @return The matching skill, or null if none match. |
| 77 | */ |
| 78 | private Skill getSkill(String tokenSource, PlayerCharacter pc, SkillDetails details, ExportHandler eh) |
| 79 | { |
| 80 | int skillIndex; |
| 81 | |
| 82 | try |
| 83 | { |
| 84 | skillIndex = Integer.parseInt(details.getSkillId()); |
| 85 | } |
| 86 | catch (NumberFormatException exc) |
| 87 | { |
| 88 | Logging.errorPrint("Error replacing SKILLTYPE." + tokenSource, exc); |
| 89 | return null; |
| 90 | } |
| 91 | |
| 92 | final List<Skill> skillSubset = new ArrayList<>(); |
| 93 | for (Skill bSkill : SkillDisplay.getSkillListInOutputOrder(pc)) |
| 94 | { |
| 95 | if (bSkill.isType(details.getProperty(0))) |
| 96 | { |
| 97 | skillSubset.add(bSkill); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | if ((skillIndex >= (skillSubset.size() - 1)) && eh != null && eh.getExistsOnly()) |
| 102 | { |
| 103 | eh.setNoMoreItems(true); |
| 104 | } |
| 105 | |
| 106 | Skill aSkill = null; |
| 107 | if (skillIndex <= (skillSubset.size() - 1)) |
| 108 | { |
| 109 | aSkill = skillSubset.get(skillIndex); |
| 110 | } |
| 111 | return aSkill; |
| 112 | } |
| 113 | |
| 114 | } |
no test coverage detected