use of pcgen.facade.core.CharacterLevelFacade in project pcgen by PCGen.
the class CharacterLevelsFacadeImpl method scanForLevelToRefundSkill.
private CharacterLevelFacade scanForLevelToRefundSkill(Skill aSkill, float testRank, PCClass classToMatch) {
for (int i = 0; i < charLevels.size(); i++) {
CharacterLevelFacade testLevel = getElementAt(i);
//Logging.errorPrint("Checking " + testLevel);
String lvlClassName = getLevelInfo(testLevel).getClassKeyName();
if (classToMatch != null && !classToMatch.getKeyName().equals(lvlClassName)) {
//Logging.errorPrint("Skipping level " + testLevel + " as it is not the same class as " + classToMatch);
continue;
}
if (!classHasRanksIn(aSkill, ((CharacterLevelFacadeImpl) testLevel).getSelectedClass())) {
//Logging.errorPrint("Skipping level " + testLevel + " as it does not have ranks in " + aSkill);
continue;
}
if (getSpentSkillPoints(testLevel) <= 0) {
//Logging.errorPrint("Skipping level " + testLevel + " as it does not have spent points.");
continue;
}
SkillCost skillCost = getSkillCost(testLevel, aSkill);
float maxRanks = getMaxRanks(testLevel, skillCost, isClassSkillForMaxRanks(testLevel, aSkill));
if (!Float.isNaN(maxRanks) && maxRanks >= testRank) {
//Logging.errorPrint("Selected level " + testLevel);
return testLevel;
}
//Logging.errorPrint("Skipping level " + testLevel + " as skill is above max ranks");
}
return null;
}
use of pcgen.facade.core.CharacterLevelFacade in project pcgen by PCGen.
the class CharacterLevelsFacadeImpl method scanForwardforLevelToBuySkill.
private CharacterLevelFacade scanForwardforLevelToBuySkill(Skill aSkill, float testRank, int baseLevelIndex, SkillCost costToMatch) {
for (int i = baseLevelIndex; i < charLevels.size(); i++) {
CharacterLevelFacade testLevel = getElementAt(i);
//Logging.errorPrint("Checking " + testLevel);
if (getRemainingSkillPoints(testLevel) <= 0) {
//Logging.errorPrint("Skipping level " + testLevel + " as it does not have points left.");
continue;
}
SkillCost skillCost = getSkillCost(testLevel, aSkill);
if (costToMatch != null && skillCost.getCost() != costToMatch.getCost()) {
//Logging.errorPrint("Skipping level " + testLevel + " as it is not the same cost as " + costToMatch);
continue;
}
float maxRanks = getMaxRanks(testLevel, skillCost, isClassSkillForMaxRanks(testLevel, aSkill));
if (!Float.isNaN(maxRanks) && maxRanks >= testRank) {
//Logging.errorPrint("Selected level " + testLevel);
return testLevel;
}
//Logging.errorPrint("Skipping level " + testLevel + " as skill is above max ranks");
}
return null;
}
use of pcgen.facade.core.CharacterLevelFacade 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.facade.core.CharacterLevelFacade in project pcgen by PCGen.
the class CharacterHPDialog method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("Reroll")) {
for (int l = 0; l < levels.getSize(); l++) {
CharacterLevelFacade level = levels.getElementAt(l);
Integer i = Integer.valueOf(levels.getClassTaken(level).getHD());
int rolled = RollingMethods.roll(i);
levels.setHPRolled(level, rolled);
}
return;
}
dispose();
}
use of pcgen.facade.core.CharacterLevelFacade in project pcgen by PCGen.
the class SkillPointTableModel method setValueAt.
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
CharacterLevelFacade level = levels.getElementAt(rowIndex);
levels.setGainedSkillPoints(level, (Integer) aValue);
}
Aggregations