Search in sources :

Example 6 with PCClass

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;
}
Also used : TreeSet(java.util.TreeSet) PCClass(pcgen.core.PCClass) HashSet(java.util.HashSet)

Example 7 with PCClass

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);
        }
    }
}
Also used : Skill(pcgen.core.Skill) SkillCost(pcgen.cdom.enumeration.SkillCost) PCClass(pcgen.core.PCClass) CharID(pcgen.cdom.enumeration.CharID) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Example 8 with PCClass

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);
        }
    }
}
Also used : Skill(pcgen.core.Skill) CDOMObject(pcgen.cdom.base.CDOMObject) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain) CharID(pcgen.cdom.enumeration.CharID) PCClassLevel(pcgen.cdom.inst.PCClassLevel)

Example 9 with PCClass

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);
        }
    }
}
Also used : Skill(pcgen.core.Skill) SkillCost(pcgen.cdom.enumeration.SkillCost) PCClass(pcgen.core.PCClass) CharID(pcgen.cdom.enumeration.CharID)

Example 10 with PCClass

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();
}
Also used : PCClass(pcgen.core.PCClass)

Aggregations

PCClass (pcgen.core.PCClass)359 Test (org.junit.Test)96 PlayerCharacter (pcgen.core.PlayerCharacter)61 Skill (pcgen.core.Skill)55 ArrayList (java.util.ArrayList)35 Domain (pcgen.core.Domain)30 LoadContext (pcgen.rules.context.LoadContext)28 PCClassLevel (pcgen.cdom.inst.PCClassLevel)26 CDOMObject (pcgen.cdom.base.CDOMObject)23 CharacterSpell (pcgen.core.character.CharacterSpell)20 Spell (pcgen.core.spell.Spell)20 StringTokenizer (java.util.StringTokenizer)19 CharID (pcgen.cdom.enumeration.CharID)19 ClassSource (pcgen.cdom.helper.ClassSource)19 PreClassTester (plugin.pretokens.test.PreClassTester)16 SkillCost (pcgen.cdom.enumeration.SkillCost)15 ParseResult (pcgen.rules.persistence.token.ParseResult)15 Ability (pcgen.core.Ability)14 Race (pcgen.core.Race)14 BonusObj (pcgen.core.bonus.BonusObj)14