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

Method testApply

code/src/java/pcgen/core/kit/KitSkill.java:129–196  ·  view source on GitHub ↗
(Kit aKit, PlayerCharacter aPC, List<String> warnings)

Source from the content-addressed store, hash-verified

127 }
128
129 @Override
130 public boolean testApply(Kit aKit, PlayerCharacter aPC, List<String> warnings)
131 {
132 skillsToAdd = new ArrayList<>();
133 List<Skill> skillChoices = getSkillChoices(aPC);
134
135 if (skillChoices == null || skillChoices.isEmpty())
136 {
137 // They didn't make a choice so don't add any ranks.
138 return false;
139 }
140 for (Skill skill : skillChoices)
141 {
142 BigDecimal ranksLeftToAdd = getRank();
143 if (ranksLeftToAdd == null)
144 {
145 ranksLeftToAdd = BigDecimal.ONE;
146 }
147 double ranksLeft = ranksLeftToAdd.doubleValue();
148 List<PCClass> classList = new ArrayList<>();
149 if (className != null)
150 {
151 String classKey = className.get().getKeyName();
152 // Make sure if they specified a class to add from we try that
153 // class first.
154 PCClass pcClass = aPC.getClassKeyed(classKey);
155 if (pcClass != null)
156 {
157 classList.add(pcClass);
158 }
159 else
160 {
161 warnings.add("SKILL: Could not find specified class " + classKey + " in PC to add ranks from.");
162 }
163 }
164 for (PCClass pcClass : aPC.getClassSet())
165 {
166 if (!classList.contains(pcClass))
167 {
168 classList.add(pcClass);
169 }
170 }
171
172 // Try and find a class we can add them from.
173 boolean oldImporting = aPC.isImporting();
174 aPC.setImporting(true);
175 for (PCClass pcClass : classList)
176 {
177 final KitSkillAdd sta = addRanks(aPC, pcClass, skill, ranksLeft, isFree(), warnings);
178 if (sta != null)
179 {
180 skillsToAdd.add(sta);
181 ranksLeft -= sta.getRanks();
182 if (ranksLeft <= 0.0)
183 {
184 break;
185 }
186 }

Callers

nothing calls this directly

Calls 15

getSkillChoicesMethod · 0.95
getRankMethod · 0.95
addRanksMethod · 0.95
isFreeMethod · 0.95
getRanksMethod · 0.95
doubleValueMethod · 0.80
isImportingMethod · 0.80
setImportingMethod · 0.80
isEmptyMethod · 0.65
getKeyNameMethod · 0.65
getMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected