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;
}
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++);
}
}
}
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;
}
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());
}
}
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());
}
}
Aggregations