use of pcgen.core.PCClass in project pcgen by PCGen.
the class SpellLevelInfo method getLevels.
public Collection<SpellLevel> getLevels(PlayerCharacter pc) {
List<SpellLevel> list = new ArrayList<>();
Converter<PCClass, PCClass> conv = new AddFilterConverter<>(new DereferencingConverter<>(pc), this);
for (PCClass cl : filter.getCollection(pc, conv)) {
int min = minimumLevel.resolve(pc, cl.getQualifiedKey()).intValue();
int max = maximumLevel.resolve(pc, cl.getQualifiedKey()).intValue();
if (min > max) {
Logging.errorPrint("Resolved Minimum: " + min + " (from " + minimumLevel + ") was greater than resolved Maximum: " + max + " (from " + maximumLevel + ")");
}
for (int i = min; i <= max; ++i) {
list.add(new SpellLevel(cl, i));
}
}
return list;
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class AbstractReferenceContext method buildDerivedObjects.
public void buildDerivedObjects() {
Collection<Domain> domains = getConstructedCDOMObjects(Domain.class);
for (Domain d : domains) {
DomainSpellList dsl = constructCDOMObject(DOMAINSPELLLIST_CLASS, d.getKeyName());
dsl.addType(Type.DIVINE);
d.put(ObjectKey.DOMAIN_SPELLLIST, dsl);
}
Collection<PCClass> classes = getConstructedCDOMObjects(PCClass.class);
for (PCClass pcc : classes) {
String key = pcc.getKeyName();
ClassSkillList skl = constructCDOMObject(CLASSSKILLLIST_CLASS, key);
boolean isMonster = pcc.isMonster();
if (isMonster) {
skl.addType(Type.MONSTER);
}
pcc.put(ObjectKey.CLASS_SKILLLIST, skl);
/*
* TODO Need to limit which are built to only spellcasters... If you
* do that, please see TO-DO in SpellListFacet
*/
ClassSpellList csl = constructCDOMObject(CLASSSPELLLIST_CLASS, key);
FactKey<String> fk = FactKey.valueOf("SpellType");
String spelltype = pcc.getResolved(fk);
if (spelltype != null) {
csl.addType(Type.getConstant(spelltype));
}
pcc.put(ObjectKey.CLASS_SPELLLIST, csl);
// for (CDOMSubClass subcl : subclasses)
if (pcc.containsListFor(ListKey.SUB_CLASS)) {
SubClassCategory cat = SubClassCategory.getConstant(key);
boolean needSelf = pcc.getSafe(ObjectKey.ALLOWBASECLASS).booleanValue();
for (SubClass subcl : pcc.getListFor(ListKey.SUB_CLASS)) {
String subKey = subcl.getKeyName();
if (subKey.equalsIgnoreCase(key)) {
//Now an error to explicitly create this match, see CODE-1928
Logging.errorPrint("Cannot explicitly create a SUBCLASS that matches the parent class. " + "Use ALLOWBASECLASS. " + "Tokens on the offending SUBCLASS line will be ignored");
pcc.removeFromListFor(ListKey.SUB_CLASS, subcl);
continue;
}
skl = constructCDOMObject(CLASSSKILLLIST_CLASS, subKey);
if (isMonster) {
skl.addType(Type.MONSTER);
}
subcl.put(ObjectKey.CLASS_SKILLLIST, skl);
// TODO Need to limit which are built to only
// spellcasters...
csl = constructCDOMObject(CLASSSPELLLIST_CLASS, subKey);
if (spelltype != null) {
csl.addType(Type.getConstant(spelltype));
}
subcl.put(ObjectKey.CLASS_SPELLLIST, csl);
// constructCDOMObject(SPELLPROGRESSION_CLASS, subKey);
/*
* CONSIDER For right now, this is easiest to do here, though
* doing this 'live' may be more appropriate in the end.
*/
subcl.setCDOMCategory(cat);
importObject(subcl);
}
if (needSelf) {
SubClass self = constructCDOMObject(SUBCLASS_CLASS, key);
reassociateCategory(SUBCLASS_CLASS, self, null, cat);
}
}
}
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class SkillSitToken method getSkillPropValue.
/**
* Evaluate the property for the supplied skill and character. For
* properties such as ACP and the extended UNTRAINED property, the
* property text is required to be further parsed to pull out user
* defined text to be output in each case.
*
* @param skillSit The skill to be reported upon.
* @param property The property to be reported.
* @param propertyText The original text of the property.
* @param pc The character to be reported upon.
* @return The value of the property.
*/
private String getSkillPropValue(Object skillSit, int property, String propertyText, PlayerCharacter pc) {
StringBuilder retValue = new StringBuilder();
if (((property == SkillToken.SKILL_ABMOD) || (property == SkillToken.SKILL_MISC)) && //&& aSkill.get(ObjectKey.KEY_STAT) == null)
false) {
retValue.append("n/a");
} else {
Skill skill;
boolean isSituation;
String situation;
SkillSituation sit;
if (skillSit instanceof Skill) {
sit = null;
skill = (Skill) skillSit;
isSituation = false;
situation = "";
} else if (skillSit instanceof SkillSituation) {
sit = (SkillSituation) skillSit;
skill = sit.getSkill();
isSituation = true;
situation = sit.getSituation();
} else {
Logging.errorPrint("Internal Error: unexpected type: " + skillSit.getClass());
return "";
}
switch(property) {
case SkillToken.SKILL_NAME:
String name = QualifiedName.qualifiedName(pc, skill);
if (isSituation) {
name += " (" + situation + ')';
}
retValue.append(name);
break;
case SkillToken.SKILL_TOTAL:
int rank = SkillRankControl.getTotalRank(pc, skill).intValue() + SkillModifier.modifier(skill, pc).intValue();
if (isSituation) {
rank += sit.getSituationBonus();
}
if (SettingsHandler.getGame().hasSkillRankDisplayText()) {
retValue.append(SettingsHandler.getGame().getSkillRankDisplayText(rank));
} else {
retValue.append(Integer.toString(rank));
}
break;
case SkillToken.SKILL_RANK:
Float sRank = SkillRankControl.getTotalRank(pc, skill);
if (SettingsHandler.getGame().hasSkillRankDisplayText()) {
retValue.append(SettingsHandler.getGame().getSkillRankDisplayText(sRank.intValue()));
} else {
retValue.append(SkillRankControl.getTotalRank(pc, skill).toString());
}
break;
case SkillToken.SKILL_MOD:
int mod = SkillModifier.modifier(skill, pc).intValue();
if (isSituation) {
mod += sit.getSituationBonus();
}
retValue.append(Integer.toString(mod));
break;
case SkillToken.SKILL_ABILITY:
retValue.append(SkillInfoUtilities.getKeyStatFromStats(pc, skill));
break;
case SkillToken.SKILL_ABMOD:
retValue.append(Integer.toString(SkillModifier.getStatMod(skill, pc)));
break;
case SkillToken.SKILL_MISC:
int misc = SkillModifier.modifier(skill, pc).intValue();
if (isSituation) {
misc += sit.getSituationBonus();
}
misc -= SkillModifier.getStatMod(skill, pc);
retValue.append(Integer.toString(misc));
break;
case SkillToken.SKILL_UNTRAINED:
retValue.append(skill.getSafe(ObjectKey.USE_UNTRAINED) ? "Y" : "NO");
break;
case SkillToken.SKILL_EXCLUSIVE:
retValue.append(skill.getSafe(ObjectKey.EXCLUSIVE) ? "Y" : "N");
break;
case SkillToken.SKILL_UNTRAINED_EXTENDED:
retValue.append(SkillToken.getUntrainedOutput(skill, propertyText));
break;
case SkillToken.SKILL_ACP:
retValue.append(SkillToken.getAcpOutput(skill, propertyText));
break;
case SkillToken.SKILL_COST:
SkillCost cost = null;
for (PCClass pcc : pc.getDisplay().getClassSet()) {
if (cost == null) {
cost = pc.getSkillCostForClass(skill, pcc);
} else {
SkillCost newCost = pc.getSkillCostForClass(skill, pcc);
if (SkillCost.CLASS.equals(newCost) || SkillCost.EXCLUSIVE.equals(cost)) {
cost = newCost;
}
}
if (SkillCost.CLASS.equals(cost)) {
break;
}
}
retValue.append(cost.toString());
break;
case SkillToken.SKILL_EXCLUSIVE_TOTAL:
int etRank = SkillRankControl.getTotalRank(pc, skill).intValue();
boolean b = (skill.getSafe(ObjectKey.EXCLUSIVE) || !skill.getSafe(ObjectKey.USE_UNTRAINED)) && (etRank == 0);
if (b) {
retValue.append('0');
} else {
int mRank = etRank + SkillModifier.modifier(skill, pc).intValue();
if (isSituation) {
mRank += sit.getSituationBonus();
}
retValue.append(Integer.toString(mRank));
}
break;
case SkillToken.SKILL_TRAINED_TOTAL:
int tRank = SkillRankControl.getTotalRank(pc, skill).intValue();
boolean isNotTrained = !skill.getSafe(ObjectKey.USE_UNTRAINED) && (tRank == 0);
if (isNotTrained) {
retValue.append('0');
} else {
int mRank = tRank + SkillModifier.modifier(skill, pc).intValue();
if (isSituation) {
mRank += sit.getSituationBonus();
}
retValue.append(Integer.toString(mRank));
}
break;
case SkillToken.SKILL_EXPLANATION:
boolean shortFrom = !("_LONG".equals(propertyText.substring(7)));
String bonusDetails = SkillCostDisplay.getModifierExplanation(skill, pc, shortFrom);
if (isSituation) {
String sitDetails = SkillCostDisplay.getSituationModifierExplanation(skill, situation, pc, shortFrom);
retValue.append(bonusDetails + " situational: " + sitDetails);
} else {
retValue.append(bonusDetails);
}
break;
case SkillToken.SKILL_TYPE:
String type = skill.getType();
retValue.append(type);
break;
case SkillToken.SKILL_SIZE:
int i = (int) (pc.getSizeAdjustmentBonusTo("SKILL", skill.getKeyName()));
if (isSituation) {
i += pc.getSizeAdjustmentBonusTo("SITUATION", skill.getKeyName() + '=' + situation);
}
retValue.append(Integer.toString(i));
break;
case SkillToken.SKILL_CLASSES:
List<String> classes = new ArrayList<>();
for (PCClass aClass : pc.getClassList()) {
if (pc.getSkillCostForClass(skill, aClass) == SkillCost.CLASS) {
classes.add(aClass.getDisplayName());
}
}
retValue.append(StringUtils.join(classes, "."));
break;
default:
Logging.errorPrint("In ExportHandler._writeSkillProperty the propIdvalue " + property + " is not handled.");
break;
}
}
return retValue.toString();
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class ClassAbbToken method getClassAbbToken.
/**
* Get the token
* @param display
* @param classNumber
* @return token
*/
public static String getClassAbbToken(CharacterDisplay display, int classNumber) {
String retString = "";
if (display.getClassCount() > classNumber) {
PCClass pcClass = display.getClassList().get(classNumber);
String subClassKey = display.getDisplayClassName(pcClass);
if (!pcClass.getKeyName().equals(subClassKey)) {
PCClass subClass = pcClass.getSubClassKeyed(subClassKey);
if (subClass != null) {
pcClass = subClass;
}
}
retString = pcClass.getAbbrev();
}
return retString;
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class ClassToken method getClassToken.
/**
* Get the token
*
* @param display
* @param classNumber
* @return token
*/
public static String getClassToken(CharacterDisplay display, int classNumber) {
String retString = "";
if (display.getClassCount() > classNumber) {
PCClass pcClass = display.getClassList().get(classNumber);
String subClassKey = display.getSubClassName(pcClass);
if (subClassKey == null || Constants.NONE.equals(subClassKey) || "".equals(subClassKey)) {
retString = OutputNameFormatting.getOutputName(pcClass);
} else {
retString = pcClass.getSubClassKeyed(subClassKey).getDisplayName();
}
}
return retString;
}
Aggregations