Search in sources :

Example 1 with ClassSkillList

use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.

the class ClassSkillListFacet method levelChanged.

@Override
public void levelChanged(ClassLevelChangeEvent lce) {
    if ((lce.getOldLevel() == 0) && (lce.getNewLevel() > 0)) {
        PCClass cl = lce.getPCClass();
        CharID id = lce.getCharID();
        TransitionChoice<ClassSkillList> csc = cl.get(ObjectKey.SKILLLIST_CHOICE);
        if (csc == null) {
            ClassSkillList l = cl.get(ObjectKey.CLASS_SKILLLIST);
            if (l != null) {
                defaultClassSkillListFacet.add(id, cl, l, cl);
            }
        } else {
            PlayerCharacter pc = trackingFacet.getPC(id);
            for (ClassSkillList st : csc.driveChoice(pc)) {
                add(id, cl, st, cl);
            }
        }
    } else if ((lce.getOldLevel() > 0) && (lce.getNewLevel() == 0)) {
        removeAllFromSource(lce.getCharID(), lce.getPCClass());
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PCClass(pcgen.core.PCClass) CharID(pcgen.cdom.enumeration.CharID) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Example 2 with ClassSkillList

use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.

the class ClassSkillListFacet method dataAdded.

@Override
public void dataAdded(ScopeFacetChangeEvent<CharID, PCClass, String> dfce) {
    PCClass cl = dfce.getScope();
    String subClassKey = dfce.getCDOMObject();
    SubClass subclass = cl.getSubClassKeyed(subClassKey);
    if (subclass != null) {
        ClassSkillList scl = subclass.get(ObjectKey.CLASS_SKILLLIST);
        defaultClassSkillListFacet.add(dfce.getCharID(), cl, scl, subclass);
    }
}
Also used : SubClass(pcgen.core.SubClass) PCClass(pcgen.core.PCClass) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Example 3 with ClassSkillList

use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.

the class ClassSkillListFacet method dataRemoved.

@Override
public void dataRemoved(ScopeFacetChangeEvent<CharID, PCClass, String> dfce) {
    PCClass cl = dfce.getScope();
    String subClassKey = dfce.getCDOMObject();
    SubClass subclass = cl.getSubClassKeyed(subClassKey);
    if (subclass != null) {
        ClassSkillList scl = subclass.get(ObjectKey.CLASS_SKILLLIST);
        defaultClassSkillListFacet.add(dfce.getCharID(), cl, scl, subclass);
    }
}
Also used : SubClass(pcgen.core.SubClass) PCClass(pcgen.core.PCClass) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Example 4 with ClassSkillList

use of pcgen.cdom.list.ClassSkillList 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);
            }
        }
    }
}
Also used : DomainSpellList(pcgen.cdom.list.DomainSpellList) SubClassCategory(pcgen.cdom.enumeration.SubClassCategory) SubClass(pcgen.core.SubClass) ClassSpellList(pcgen.cdom.list.ClassSpellList) Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Example 5 with ClassSkillList

use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.

the class SkillListToCostFacet method dataAdded.

@Override
public void dataAdded(ScopeFacetChangeEvent<CharID, PCClass, ClassSkillList> dfce) {
    CharID id = dfce.getCharID();
    ClassSkillList skilllist = dfce.getCDOMObject();
    Collection<Skill> set = masterSkillFacet.getSet(id.getDatasetID(), skilllist);
    if (set != null) {
        PCClass pcc = dfce.getScope();
        for (Skill s : set) {
            add(id, pcc, SkillCost.CLASS, s, skilllist);
        }
    }
}
Also used : Skill(pcgen.core.Skill) PCClass(pcgen.core.PCClass) CharID(pcgen.cdom.enumeration.CharID) ClassSkillList(pcgen.cdom.list.ClassSkillList)

Aggregations

ClassSkillList (pcgen.cdom.list.ClassSkillList)25 CDOMReference (pcgen.cdom.base.CDOMReference)8 PCClass (pcgen.core.PCClass)8 Skill (pcgen.core.Skill)8 Test (org.junit.Test)6 CharID (pcgen.cdom.enumeration.CharID)6 ArrayList (java.util.ArrayList)5 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)5 StringTokenizer (java.util.StringTokenizer)4 ParseResult (pcgen.rules.persistence.token.ParseResult)4 SkillCost (pcgen.cdom.enumeration.SkillCost)3 SubClass (pcgen.core.SubClass)3 Formula (pcgen.base.formula.Formula)2 ChoiceSet (pcgen.cdom.base.ChoiceSet)2 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)2 Race (pcgen.core.Race)2 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)2 CDOMObject (pcgen.cdom.base.CDOMObject)1 ChooseSelectionActor (pcgen.cdom.base.ChooseSelectionActor)1 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)1