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)
| 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() |
no test coverage detected