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

Method getMaxRank

code/src/java/pcgen/core/PlayerCharacter.java:3182–3234  ·  view source on GitHub ↗

Calculate the maximum number of ranks the character is allowed to have in the specified skill. @param aSkill The skill being checked. @param aClass The name of the current class in which points are being spent - only used to check cross-class skill cost. @return max rank

(Skill aSkill, final PCClass aClass)

Source from the content-addressed store, hash-verified

3180 * @return max rank
3181 */
3182 public Float getMaxRank(Skill aSkill, final PCClass aClass)
3183 {
3184 int levelForSkillPurposes = getTotalLevels();
3185 final BigDecimal maxRanks;
3186
3187 if (aSkill == null)
3188 {
3189 return 0.0f;
3190 }
3191 if (aSkill.getSafe(ObjectKey.EXCLUSIVE))
3192 {
3193 // Exclusive skills only count levels in classes which give access
3194 // to the skill
3195 levelForSkillPurposes = 0;
3196
3197 for (PCClass bClass : getClassSet())
3198 {
3199 if (this.isClassSkill(bClass, aSkill))
3200 {
3201 levelForSkillPurposes += getLevel(bClass);
3202 }
3203 }
3204
3205 if (levelForSkillPurposes == 0)
3206 {
3207 // No classes qualify for this exclusive skill, so treat it as a
3208 // cross-class skill
3209 // This does not seem right to me! JD
3210 levelForSkillPurposes = (getTotalLevels());
3211
3212 maxRanks = SkillUtilities.maxCrossClassSkillForLevel(levelForSkillPurposes, this);
3213 } else
3214 {
3215 maxRanks = SkillUtilities.maxClassSkillForLevel(levelForSkillPurposes, this);
3216 }
3217 } else if (!this.isClassSkill(aSkill) && (this.getSkillCostForClass(aSkill, aClass) == SkillCost.CLASS))
3218 {
3219 // Cross class skill - but as cost is 1 only return a whole number
3220 maxRanks =
3221 new BigDecimal(
3222 SkillUtilities.maxCrossClassSkillForLevel(
3223 levelForSkillPurposes, this).intValue()); // This was (int) (i/2.0) previously
3224 } else if (!this.isClassSkill(aSkill))
3225 {
3226 // Cross class skill
3227 maxRanks = SkillUtilities.maxCrossClassSkillForLevel(levelForSkillPurposes, this);
3228 } else
3229 {
3230 // Class skill
3231 maxRanks = SkillUtilities.maxClassSkillForLevel(levelForSkillPurposes, this);
3232 }
3233 return maxRanks.floatValue();
3234 }
3235
3236 /**
3237 * Checks if the stat is a non ability.

Callers 5

allowMethod · 0.45
getTotalRankMethod · 0.45
modRanksMethod · 0.45
addRanksMethod · 0.45

Calls 10

getTotalLevelsMethod · 0.95
getClassSetMethod · 0.95
isClassSkillMethod · 0.95
getLevelMethod · 0.95
maxClassSkillForLevelMethod · 0.95
getSkillCostForClassMethod · 0.95
getSafeMethod · 0.80
intValueMethod · 0.80
floatValueMethod · 0.80

Tested by

no test coverage detected