Search in sources :

Example 1 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class CharacterDisplay method getRacialHDSize.

public int getRacialHDSize() {
    int hdSize = 0;
    LevelCommandFactory lcf = getRace().get(ObjectKey.MONSTER_CLASS);
    if (lcf != null) {
        hdSize = getLevelHitDie(lcf.getPCClass(), 1).getDie();
    }
    return hdSize;
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory)

Example 2 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class MonsterClassFacet method dataRemoved.

/**
	 * Removes monster classes from the Player Character when the CDOMObject
	 * which granted the monster classes is removed from the Player Character.
	 * 
	 * Triggered when one of the Facets to which MonsterClassFacet listens fires
	 * a DataFacetChangeEvent to indicate a CDOMObject was removed from a Player
	 * Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataRemoved(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataRemoved(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
    CDOMObject cdo = dfce.getCDOMObject();
    LevelCommandFactory lcf = cdo.get(ObjectKey.MONSTER_CLASS);
    if (lcf != null) {
        CharID id = dfce.getCharID();
        int levelCount = formulaResolvingFacet.resolve(id, lcf.getLevelCount(), "").intValue();
        PlayerCharacter pc = trackingFacet.getPC(id);
        pc.incrementClassLevel(-levelCount, lcf.getPCClass(), true);
    }
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PlayerCharacter(pcgen.core.PlayerCharacter) CDOMObject(pcgen.cdom.base.CDOMObject) CharID(pcgen.cdom.enumeration.CharID)

Example 3 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class MonsterClassFacet method dataAdded.

/**
	 * Adds monster classes to the Player Character when a CDOMObject which
	 * grants monster classes is added to the Player Character.
	 * 
	 * Triggered when one of the Facets to which MonsterClassFacet 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) {
    CharID id = dfce.getCharID();
    CDOMObject cdo = dfce.getCDOMObject();
    // Get existing classes
    ClassInfo ci = classFacet.removeAllClasses(id);
    //
    for (int i = levelInfoFacet.getCount(id) - 1; i >= 0; --i) {
        PCLevelInfo pli = levelInfoFacet.get(id, i);
        final String classKeyName = pli.getClassKeyName();
        final PCClass aClass = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, classKeyName);
        if (aClass.isMonster()) {
            levelInfoFacet.remove(id, pli);
        }
    }
    PlayerCharacter pc = trackingFacet.getPC(id);
    final List<PCLevelInfo> existingLevelInfo = new ArrayList<>(levelInfoFacet.getSet(id));
    levelInfoFacet.removeAll(id);
    // Make sure monster classes are added first
    if (!pc.isImporting()) {
        LevelCommandFactory lcf = cdo.get(ObjectKey.MONSTER_CLASS);
        if (lcf != null) {
            int levelCount = formulaResolvingFacet.resolve(id, lcf.getLevelCount(), "").intValue();
            pc.incrementClassLevel(levelCount, lcf.getPCClass(), true);
        }
    }
    levelInfoFacet.addAll(id, existingLevelInfo);
    //
    if (!pc.isImporting() && ci != null && !ci.isEmpty()) {
        int totalLevels = levelFacet.getTotalLevels(id);
        for (PCClass pcClass : ci.getClassSet()) {
            //
            if (!pcClass.isMonster()) {
                classFacet.addClass(id, pcClass);
                int cLevels = ci.getLevel(pcClass);
                classFacet.setLevel(id, pcClass, cLevels);
                pc.setSkillPool(pcClass, 0);
                int cMod = 0;
                for (int j = 0; j < cLevels; ++j) {
                    cMod += pc.recalcSkillPointMod(pcClass, ++totalLevels);
                }
                pc.setSkillPool(pcClass, cMod);
            }
        }
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) CDOMObject(pcgen.cdom.base.CDOMObject) ArrayList(java.util.ArrayList) PCLevelInfo(pcgen.core.pclevelinfo.PCLevelInfo) PCClass(pcgen.core.PCClass) CharID(pcgen.cdom.enumeration.CharID) ClassInfo(pcgen.cdom.facet.model.ClassFacet.ClassInfo)

Example 4 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class AddLevelFacet method dataRemoved.

/**
	 * Drives the necessary removal of the results of an ADDLEVEL: token to
	 * remove the added levels from a Player Character because the object
	 * granting the ADDLEVEL: was removed from the Player Character.
	 * 
	 * Triggered when one of the Facets to which AddLevelFacet 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 dataRemoved(DataFacetChangeEvent<CharID, PCTemplate> dfce) {
    PCTemplate template = dfce.getCDOMObject();
    CharID id = dfce.getCharID();
    PlayerCharacter pc = trackingFacet.getPC(id);
    List<LevelCommandFactory> lcfList = template.getSafeListFor(ListKey.ADD_LEVEL);
    for (ListIterator<LevelCommandFactory> it = lcfList.listIterator(lcfList.size()); it.hasPrevious(); ) {
        LevelCommandFactory lcf = it.previous();
        remove(lcf.getLevelCount(), lcf.getPCClass(), pc);
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID)

Example 5 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class PreLevelTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    PCClass raceClass = new PCClass();
    raceClass.setName("Race Class");
    raceClass.put(StringKey.KEY_NAME, "RaceClass");
    Globals.getContext().getReferenceContext().importObject(raceClass);
    race.setName("Gnoll");
    race.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(raceClass), FormulaFactory.getFormulaFor(2)));
    myClass.setName("My Class");
    myClass.put(StringKey.KEY_NAME, "MY_CLASS");
    myClass.put(FormulaKey.START_SKILL_POINTS, FormulaFactory.getFormulaFor(3));
    Globals.getContext().getReferenceContext().importObject(myClass);
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PCClass(pcgen.core.PCClass)

Aggregations

LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)25 PCClass (pcgen.core.PCClass)10 PlayerCharacter (pcgen.core.PlayerCharacter)7 CharID (pcgen.cdom.enumeration.CharID)4 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Race (pcgen.core.Race)3 SizeAdjustment (pcgen.core.SizeAdjustment)3 LoadContext (pcgen.rules.context.LoadContext)3 URI (java.net.URI)2 ParsingSeparator (pcgen.base.text.ParsingSeparator)2 CDOMObject (pcgen.cdom.base.CDOMObject)2 PCTemplate (pcgen.core.PCTemplate)2 BonusObj (pcgen.core.bonus.BonusObj)2 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)2 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)2 PCClassLoader (pcgen.persistence.lst.PCClassLoader)2 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)2 PcgCombatant (gmgen.plugin.PcgCombatant)1