use of pcgen.cdom.enumeration.SkillCost in project pcgen by PCGen.
the class MonCSkillToSkillCostFacet method dataAdded.
@Override
public void dataAdded(DataFacetChangeEvent<CharID, PCClass> dfce) {
PCClass cl = dfce.getCDOMObject();
if (cl.isMonster()) {
CharID id = dfce.getCharID();
SkillCost cost = SkillCost.CLASS;
for (Skill sk : monsterCSkillFacet.getSet(id)) {
add(id, cl, cost, sk, monsterCSkillFacet);
}
}
}
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) {
float usedPoints = 0;
for (Skill aSkill : pc.getDisplay().getSkillSet()) {
for (PCClass pcc : pc.getSkillRankClasses(aSkill)) {
Double rank = pc.getSkillRankForClass(aSkill, pcc);
if (rank == null) {
rank = 0.0d;
}
SkillCost skillCost = pc.getSkillCostForClass(aSkill, pcc);
usedPoints += (rank * skillCost.getCost());
}
}
return (int) usedPoints;
}
use of pcgen.cdom.enumeration.SkillCost in project pcgen by PCGen.
the class SkillCostTableModel method getValueAt.
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
int index = selectionModel.getMinSelectionIndex();
CharacterLevelFacade level = null;
if (index != -1) {
level = levels.getElementAt(index);
}
SkillCost cost = SkillCost.values()[rowIndex];
switch(columnIndex) {
case 0:
return cost;
case 1:
if (levels == null) {
return 0;
}
return levels.getRankCost(level, cost);
case 2:
if (levels == null) {
return 0.0;
}
return levels.getMaxRanks(level, cost, false);
default:
throw new IndexOutOfBoundsException();
}
}
use of pcgen.cdom.enumeration.SkillCost 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.cdom.enumeration.SkillCost 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;
}
Aggregations