Search in sources :

Example 21 with SkillCost

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;
}
Also used : Skill(pcgen.core.Skill) CharacterDisplay(pcgen.core.display.CharacterDisplay) SkillCost(pcgen.cdom.enumeration.SkillCost) PCClass(pcgen.core.PCClass)

Example 22 with SkillCost

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 "";
}
Also used : SkillCost(pcgen.cdom.enumeration.SkillCost)

Aggregations

SkillCost (pcgen.cdom.enumeration.SkillCost)22 Skill (pcgen.core.Skill)16 PCClass (pcgen.core.PCClass)15 CharID (pcgen.cdom.enumeration.CharID)11 CharacterLevelFacade (pcgen.facade.core.CharacterLevelFacade)4 ArrayList (java.util.ArrayList)3 ClassSkillList (pcgen.cdom.list.ClassSkillList)3 DataSetID (pcgen.cdom.enumeration.DataSetID)2 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)1 CDOMObject (pcgen.cdom.base.CDOMObject)1 CDOMReference (pcgen.cdom.base.CDOMReference)1 SkillSituation (pcgen.cdom.helper.SkillSituation)1 CharacterDisplay (pcgen.core.display.CharacterDisplay)1 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)1