MCPcopy Create free account
hub / github.com/PCGen/pcgen / getSkill

Method getSkill

code/src/java/plugin/exporttokens/SkillTypeToken.java:78–112  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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}

Callers 1

getTokenMethod · 0.95

Calls 11

errorPrintMethod · 0.95
parseIntMethod · 0.80
getSkillIdMethod · 0.80
getExistsOnlyMethod · 0.80
setNoMoreItemsMethod · 0.80
isTypeMethod · 0.65
addMethod · 0.65
sizeMethod · 0.65
getMethod · 0.65
getPropertyMethod · 0.45

Tested by

no test coverage detected