Select the target skill based on the supplied criteria. Uses the id in the details object to either retrieve a skill by name or by position in the skill list. @param pc The character being processed. @param details The parsed details of the token. @param eh The ExportHandler @return The matching sk
(PlayerCharacter pc, SkillDetails details, ExportHandler eh)
| 112 | * @return The matching skill, or null if none match. |
| 113 | */ |
| 114 | private Skill getSkill(PlayerCharacter pc, SkillDetails details, ExportHandler eh) |
| 115 | { |
| 116 | Skill skill = null; |
| 117 | try |
| 118 | { |
| 119 | final int i = Integer.parseInt(details.getSkillId()); |
| 120 | final List<Skill> pcSkills = new ArrayList<>(getSkillList(pc)); |
| 121 | |
| 122 | SkillFilter filter = details.getSkillFilter(); |
| 123 | if (filter == null || filter == SkillFilter.Selected) |
| 124 | { |
| 125 | filter = pc.getSkillFilter(); |
| 126 | } |
| 127 | |
| 128 | Iterator<Skill> iter = pcSkills.iterator(); |
| 129 | while (iter.hasNext()) |
| 130 | { |
| 131 | Skill sk = iter.next(); |
| 132 | if (!pc.includeSkill(sk, filter) || !sk.qualifies(pc, null)) |
| 133 | { |
| 134 | iter.remove(); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | if ((i >= (pcSkills.size() - 1)) && eh != null && eh.getExistsOnly()) |
| 139 | { |
| 140 | eh.setNoMoreItems(true); |
| 141 | } |
| 142 | |
| 143 | if (i < pcSkills.size()) |
| 144 | { |
| 145 | skill = pcSkills.get(i); |
| 146 | } |
| 147 | } |
| 148 | catch (NumberFormatException exc) |
| 149 | { |
| 150 | //Allowing SKILL.Spot.<subtoken> |
| 151 | skill = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Skill.class, |
| 152 | details.getSkillId()); |
| 153 | } |
| 154 | return skill; |
| 155 | } |
| 156 | |
| 157 | private synchronized List<Skill> getSkillList(PlayerCharacter pc) |
| 158 | { |
no test coverage detected