Search in sources :

Example 31 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class SkillDisplay method getHighestOutputIndex.

/**
	 * Retrieve the highest output index used in any of the
	 * character's skills.
	 * @return highest output index
	 */
private static int getHighestOutputIndex(PlayerCharacter pc) {
    int maxOutputIndex = 0;
    final Iterable<Skill> skillList = new ArrayList<>(pc.getSkillSet());
    for (Skill bSkill : skillList) {
        Integer outputIndex = pc.getSkillOrder(bSkill);
        if (outputIndex != null && outputIndex > maxOutputIndex) {
            maxOutputIndex = outputIndex;
        }
    }
    return maxOutputIndex;
}
Also used : Skill(pcgen.core.Skill) ArrayList(java.util.ArrayList)

Example 32 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class SkillDisplay method resortSelected.

private static void resortSelected(PlayerCharacter pc, SkillComparator comparator) {
    if ((pc == null) || (comparator == null)) {
        return;
    }
    List<Skill> skillList = new ArrayList<>(pc.getSkillSet());
    skillList.sort(comparator);
    int nextOutputIndex = 1;
    for (final Skill aSkill : skillList) {
        Integer outputIndex = pc.getSkillOrder(aSkill);
        if ((outputIndex == null) || (outputIndex >= 0)) {
            pc.setSkillOrder(aSkill, nextOutputIndex++);
        }
    }
}
Also used : Skill(pcgen.core.Skill) ArrayList(java.util.ArrayList)

Example 33 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class CharacterLevelsFacadeImpl method findNextLevelForSkill.

@Override
public CharacterLevelFacade findNextLevelForSkill(SkillFacade skill, CharacterLevelFacade baseLevel, float newRank) {
    Skill aSkill = (Skill) skill;
    SkillCost skillCost = getSkillCost(baseLevel, aSkill);
    float maxRanks = getMaxRanks(baseLevel, skillCost, isClassSkillForMaxRanks(baseLevel, aSkill));
    float currRank = SkillRankControl.getTotalRank(theCharacter, aSkill);
    if (newRank < currRank) {
        // 1. Selected level (if class had purchased a rank and is not above max ranks)
        if (classHasRanksIn(skill, ((CharacterLevelFacadeImpl) baseLevel).getSelectedClass()) && !Float.isNaN(maxRanks) && maxRanks >= currRank && getSpentSkillPoints(baseLevel) > 0) {
            return baseLevel;
        }
        // 2. Scan from level 1 for first level of the same class as currently 
        // selected level in which the rank to be removed is below max ranks and 
        // is a class that has bought ranks in the class
        CharacterLevelFacade levelToRefundSkill = scanForLevelToRefundSkill(aSkill, currRank, (PCClass) getClassTaken(baseLevel));
        if (levelToRefundSkill != null) {
            return levelToRefundSkill;
        }
        // 3. Scan from level 1 for first level of any class in which the rank 
        // to be removed is below max ranks and is a class that has bought 
        // ranks in the class
        levelToRefundSkill = scanForLevelToRefundSkill(aSkill, currRank, null);
        return levelToRefundSkill;
    }
    // Check if current level ok
    if (!Float.isNaN(maxRanks) && maxRanks >= newRank && getRemainingSkillPoints(baseLevel) > 0) {
        return baseLevel;
    }
    // Check for class cost on this level or higher
    int baseLevelIndex = getLevelIndex(baseLevel);
    CharacterLevelFacade levelToBuySkill = scanForwardforLevelToBuySkill(aSkill, newRank, baseLevelIndex, SkillCost.CLASS);
    if (levelToBuySkill != null) {
        return levelToBuySkill;
    }
    // Check for class cost on any level
    levelToBuySkill = scanForwardforLevelToBuySkill(aSkill, newRank, 0, SkillCost.CLASS);
    if (levelToBuySkill != null) {
        return levelToBuySkill;
    }
    // Check for any cost on this level or higher
    levelToBuySkill = scanForwardforLevelToBuySkill(aSkill, newRank, baseLevelIndex, null);
    if (levelToBuySkill != null) {
        return levelToBuySkill;
    }
    // Check for any cost on any level
    levelToBuySkill = scanForwardforLevelToBuySkill(aSkill, newRank, 0, null);
    return levelToBuySkill;
}
Also used : CharacterLevelFacade(pcgen.facade.core.CharacterLevelFacade) Skill(pcgen.core.Skill) SkillCost(pcgen.cdom.enumeration.SkillCost)

Example 34 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class SkillFacet method rankChanged.

@Override
public void rankChanged(SkillRankChangeEvent lce) {
    CharID id = lce.getCharID();
    Skill skill = lce.getSkill();
    if (lce.getNewRank() == 0.0f) {
        remove(id, skill, lce.getSource());
    } else {
        add(id, skill, lce.getSource());
    }
}
Also used : Skill(pcgen.core.Skill) CharID(pcgen.cdom.enumeration.CharID)

Example 35 with Skill

use of pcgen.core.Skill in project pcgen by PCGen.

the class SkillFacet method bonusChange.

@Override
public void bonusChange(AssociationChangeEvent dfce) {
    CharID id = dfce.getCharID();
    Skill sk = dfce.getSkill();
    Number ranks = dfce.getNewVal();
    if (ranks.doubleValue() > 0) {
        add(id, sk, dfce.getSource());
    } else {
        remove(id, sk, dfce.getSource());
    }
}
Also used : Skill(pcgen.core.Skill) CharID(pcgen.cdom.enumeration.CharID)

Aggregations

Skill (pcgen.core.Skill)165 Test (org.junit.Test)60 PCClass (pcgen.core.PCClass)55 ArrayList (java.util.ArrayList)29 CDOMReference (pcgen.cdom.base.CDOMReference)24 CharID (pcgen.cdom.enumeration.CharID)23 SkillCost (pcgen.cdom.enumeration.SkillCost)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 PlayerCharacter (pcgen.core.PlayerCharacter)14 ChoiceSet (pcgen.cdom.base.ChoiceSet)13 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)13 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)13 ClassSkillChoiceActor (pcgen.cdom.helper.ClassSkillChoiceActor)13 StringTokenizer (java.util.StringTokenizer)10 ObjectMatchingReference (pcgen.cdom.reference.ObjectMatchingReference)10 Ability (pcgen.core.Ability)10 LoadContext (pcgen.rules.context.LoadContext)9 ClassSkillList (pcgen.cdom.list.ClassSkillList)8 HashSet (java.util.HashSet)7 CNAbility (pcgen.cdom.content.CNAbility)7