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

Method updatePCSkills

code/src/java/pcgen/core/kit/KitSkill.java:222–274  ·  view source on GitHub ↗

Needs documentation. @param pc update skills for this PC @param aSkill Skill to update @param aRank Number of ranks to add @param aCost Cost of added ranks @param langList Languages to be selected for a language skill @param pcClass skills apply to this class @return true for success TODO

(final PlayerCharacter pc, final Skill aSkill, final int aRank, final double aCost,
		List<Language> langList, final PCClass pcClass)

Source from the content-addressed store, hash-verified

220 * TODO What about throwing on failure?
221 */
222 private boolean updatePCSkills(final PlayerCharacter pc, final Skill aSkill, final int aRank, final double aCost,
223 List<Language> langList, final PCClass pcClass)
224 {
225 boolean oldImporting = pc.isImporting();
226 pc.setImporting(true);
227 final String aString = SkillRankControl.modRanks(aRank, pcClass, true, pc, aSkill);
228 pc.setImporting(oldImporting);
229
230 if (!aString.isEmpty())
231 {
232 Logging.errorPrint("SKILL: " + aString);
233 return false;
234 }
235
236 // Add any supplied languages
237 ChoiceManagerList<Language> controller =
238 ChooserUtilities.getConfiguredController(aSkill, pc, null, new ArrayList<>());
239 for (Language lang : langList)
240 {
241 if (!controller.conditionallyApply(pc, lang))
242 {
243 Logging.errorPrint("Failed to apply Language into Skill: " + lang.getKeyName());
244 }
245 }
246
247 //
248 // Fix up the skill pools to reflect what we just spent.
249 //
250 double ptsToSpend = aCost;
251 if (ptsToSpend >= 0.0)
252 {
253 for (PCLevelInfo info : pc.getLevelInfo())
254 {
255 if (info.getClassKeyName().equals(pcClass.getKeyName()))
256 {
257 // We are spending this class' points.
258 int remaining = info.getSkillPointsRemaining();
259 if (remaining == 0)
260 {
261 continue;
262 }
263 int left = remaining - (int) Math.min(remaining, ptsToSpend);
264 info.setSkillPointsRemaining(left);
265 ptsToSpend -= (remaining - left);
266 if (ptsToSpend <= 0)
267 {
268 break;
269 }
270 }
271 }
272 }
273 return true;
274 }
275
276 @Override
277 public String getObjectName()

Callers 1

applyMethod · 0.95

Calls 14

modRanksMethod · 0.95
errorPrintMethod · 0.95
isImportingMethod · 0.80
setImportingMethod · 0.80
getClassKeyNameMethod · 0.80
isEmptyMethod · 0.65
conditionallyApplyMethod · 0.65
getKeyNameMethod · 0.65
equalsMethod · 0.65

Tested by

no test coverage detected