use of pcgen.cdom.enumeration.SkillCost in project pcgen by PCGen.
the class SkillpointsToken method getUsedSkillPoints.
/**
* Get the used skill points for the PC
* @param pc
* @return the used skill points for the PC
*/
public static int getUsedSkillPoints(PlayerCharacter pc, int classNum) {
CharacterDisplay display = pc.getDisplay();
if (classNum < 0 || classNum >= display.getClassCount()) {
return 0;
}
PCClass targetClass = display.getClassList().get(classNum);
float usedPoints = 0;
for (Skill aSkill : display.getSkillSet()) {
Integer outputIndex = pc.getSkillOrder(aSkill);
if ((pc.getRank(aSkill).doubleValue() > 0) || (outputIndex != null && outputIndex != 0)) {
Double rank = pc.getSkillRankForClass(aSkill, targetClass);
if (rank == null) {
rank = 0.0d;
}
SkillCost skillCost = pc.getSkillCostForClass(aSkill, targetClass);
usedPoints += (rank * skillCost.getCost());
}
}
return (int) usedPoints;
}
use of pcgen.cdom.enumeration.SkillCost in project pcgen by PCGen.
the class SkillRankControl method modRanks.
/**
* Modify the rank
*
* @param rankMod
* @param aClass
* @param ignorePrereqs
* @param aPC
* @return message
*/
public static String modRanks(double rankMod, PCClass aClass, boolean ignorePrereqs, PlayerCharacter aPC, Skill sk) {
int i = 0;
if (!ignorePrereqs) {
if (aClass == null) {
return "You must be at least level one before you can purchase skills.";
}
if ((rankMod > 0.0) && !sk.qualifies(aPC, sk)) {
return "You do not meet the prerequisites required to take this skill.";
}
SkillCost sc = aPC.getSkillCostForClass(sk, aClass);
i = sc.getCost();
if (i == 0) {
return "You cannot purchase this exclusive skill.";
}
if ((rankMod > 0.0) && (aClass.getSkillPool(aPC) < (rankMod * i))) {
return "You do not have enough skill points.";
}
double maxRank = aPC.getMaxRank(sk, aClass).doubleValue();
if (!Globals.checkRule(RuleConstants.SKILLMAX) && (rankMod > 0.0)) {
double ttlRank = getTotalRank(aPC, sk).doubleValue();
if (ttlRank >= maxRank) {
return "Skill rank at maximum (" + maxRank + ") for your level.";
}
if ((ttlRank + rankMod) > maxRank) {
return "Raising skill would make it above maximum (" + maxRank + ") for your level.";
}
}
}
if ((aPC.getRank(sk).doubleValue() + rankMod) < 0.0) {
return "Cannot lower rank below 0";
}
String classKey = "None";
if (aClass != null) {
classKey = aClass.getKeyName();
}
Double rank = aPC.getSkillRankForClass(sk, aClass);
double currentRank = (rank == null) ? 0.0 : rank;
if (CoreUtility.doublesEqual(currentRank, 0.0) && (rankMod < 0.0)) {
return "No more ranks found for class: " + classKey + ". Try a different one.";
}
rankMod = modRanks2(rankMod, currentRank, aClass, aPC, sk);
if (!ignorePrereqs) {
if (aClass != null) {
aPC.setSkillPool(aClass, aClass.getSkillPool(aPC) - (int) (i * rankMod));
}
}
return "";
}
Aggregations