use of pcgen.core.PCClass in project pcgen by PCGen.
the class MultiClassFacet method getMultiClassXPMultiplier.
/**
* Returns the multi-class XP multiplier for the Player Character identified
* by the given CharID.
*
* @param id
* The CharID identifying the Player Character for which the
* multi-class XP multipler is to be returned
* @return The multi-class XP multiplier for the Player Character identified
* by the given CharID
*/
public double getMultiClassXPMultiplier(CharID id) {
Set<PCClass> unfavoredClasses = new HashSet<>();
SortedSet<PCClass> favored = new TreeSet<>(CDOMObjectUtilities.CDOM_SORTER);
favored.addAll(favoredClassFacet.getSet(id));
SortedSet<PCClass> aList = favored;
boolean hasAny = hasAnyFavoredClassFacet.contains(id, Boolean.TRUE);
PCClass maxClass = null;
PCClass secondClass = null;
int maxClassLevel = 0;
int secondClassLevel = 0;
double xpMultiplier = 1.0;
for (PCClass pcClass : classFacet.getSet(id)) {
if (!pcClass.hasXPPenalty()) {
continue;
}
String subClassKey = subClassFacet.get(id, pcClass);
PCClass evalClass = pcClass;
if (subClassKey != null && !subClassKey.equals("None")) {
evalClass = pcClass.getSubClassKeyed(subClassKey);
}
if (!aList.contains(evalClass)) {
unfavoredClasses.add(pcClass);
int pcClassLevel = classFacet.getLevel(id, pcClass);
if (pcClassLevel > maxClassLevel) {
if (hasAny) {
secondClassLevel = maxClassLevel;
secondClass = maxClass;
}
maxClassLevel = pcClassLevel;
maxClass = pcClass;
} else if ((pcClassLevel > secondClassLevel) && (hasAny)) {
secondClassLevel = pcClassLevel;
secondClass = pcClass;
}
}
}
if ((hasAny) && (secondClassLevel > 0)) {
maxClassLevel = secondClassLevel;
unfavoredClasses.remove(maxClass);
maxClass = secondClass;
}
if (maxClassLevel > 0) {
unfavoredClasses.remove(maxClass);
int xpPenalty = 0;
for (PCClass aClass : unfavoredClasses) {
if ((maxClassLevel - (classFacet.getLevel(id, aClass))) > 1) {
++xpPenalty;
}
}
xpMultiplier = 1.0 - (xpPenalty * 0.2);
if (xpMultiplier < 0) {
xpMultiplier = 0;
}
}
return xpMultiplier;
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class ListToSkillCostFacet method dataRemoved.
@Override
public void dataRemoved(SubScopeFacetChangeEvent<ClassSkillList, SkillCost, Skill> dfce) {
CharID id = dfce.getCharID();
ClassSkillList skilllist = dfce.getScope1();
SkillCost cost = dfce.getScope2();
Skill sk = dfce.getCDOMObject();
for (PCClass cl : skillListFacet.getScopes(id)) {
if (skillListFacet.contains(id, cl, skilllist)) {
remove(id, cl, cost, sk, cl);
}
}
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class LocalSkillCostFacet method dataAdded.
/**
* Adds the SkillCost objects granted by CDOMObjects, as applied directly to
* a PCClass, when a CDOMObject is added to a Player Character.
*
* Triggered when one of the Facets to which LocalSkillCostFacet listens
* fires a DataFacetChangeEvent to indicate a CDOMObject was added to a
* Player Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
CDOMObject cdo = dfce.getCDOMObject();
CharID id = dfce.getCharID();
PCClass owner;
if (cdo instanceof Domain) {
owner = domainFacet.getSource(id, (Domain) cdo).getPcclass();
} else if (cdo instanceof PCClassLevel) {
owner = (PCClass) cdo.get(ObjectKey.PARENT);
} else if (cdo instanceof PCClass) {
owner = (PCClass) cdo;
} else {
Logging.errorPrint(getClass().getSimpleName() + " was given " + cdo + " which is not an expected object type");
return;
}
for (CDOMReference<Skill> ref : cdo.getSafeListFor(ListKey.LOCALCSKILL)) {
for (Skill sk : ref.getContainedObjects()) {
add(id, owner, SkillCost.CLASS, sk, cdo);
}
}
for (CDOMReference<Skill> ref : cdo.getSafeListFor(ListKey.LOCALCCSKILL)) {
for (Skill sk : ref.getContainedObjects()) {
add(id, owner, SkillCost.CROSS_CLASS, sk, cdo);
}
}
}
use of pcgen.core.PCClass 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.core.PCClass in project pcgen by PCGen.
the class CharacterDisplay method getFullDisplayClassName.
private String getFullDisplayClassName() {
if (classFacet.isEmpty(id)) {
return "Nobody";
}
final StringBuilder buf = new StringBuilder(50);
boolean first = true;
for (PCClass c : getClassSet()) {
if (!first) {
buf.append('/');
first = false;
}
buf.append(getFullDisplayClassName(c));
}
return buf.toString();
}
Aggregations