/** * Initializes the connections for StartingLanguageFacet to other facets. * * <p>This method is automatically called by the Spring framework during initialization of the * StartingLanguageFacet. */ public void init() { raceFacet.addDataFacetChangeListener(this); templateFacet.addDataFacetChangeListener(this); conditionalTemplateFacet.addDataFacetChangeListener(this); classFacet.addDataFacetChangeListener(this); }
public double getMultiClassXPMultiplier(CharID id) { HashSet<PCClass> unfavoredClasses = new HashSet<PCClass>(); SortedSet<PCClass> favored = new TreeSet<PCClass>(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; int xpPenalty = 0; double xpMultiplier = 1.0; for (PCClass pcClass : classFacet.getClassSet(id)) { if (!pcClass.hasXPPenalty()) { continue; } String subClassKey = subClassFacet.getSource(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); 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; }