Search in sources :

Example 6 with SubClass

use of pcgen.core.SubClass 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 7 with SubClass

use of pcgen.core.SubClass 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 8 with SubClass

use of pcgen.core.SubClass in project pcgen by PCGen.

the class FavoredClassTokenTest method testCategorizationFail.

@Test
public void testCategorizationFail() throws PersistenceLayerException {
    construct(primaryContext, "TestWP1");
    assertTrue(parse("TestWP1.Two"));
    SubClass obj = primaryContext.getReferenceContext().constructCDOMObject(SubClass.class, "Two");
    SubClassCategory cat = SubClassCategory.getConstant("TestWP2");
    primaryContext.getReferenceContext().reassociateCategory(cat, obj);
    assertConstructionError();
}
Also used : SubClass(pcgen.core.SubClass) SubClassCategory(pcgen.cdom.enumeration.SubClassCategory) Test(org.junit.Test)

Example 9 with SubClass

use of pcgen.core.SubClass in project pcgen by PCGen.

the class FavoredClassTokenTest method testCategorizationPass.

@Test
public void testCategorizationPass() throws PersistenceLayerException {
    construct(primaryContext, "TestWP1");
    assertTrue(parse("TestWP1.Two"));
    SubClass obj = primaryContext.getReferenceContext().constructCDOMObject(SubClass.class, "Two");
    SubClassCategory cat = SubClassCategory.getConstant("TestWP2");
    primaryContext.getReferenceContext().reassociateCategory(cat, obj);
    obj = primaryContext.getReferenceContext().constructCDOMObject(SubClass.class, "Two");
    cat = SubClassCategory.getConstant("TestWP1");
    primaryContext.getReferenceContext().reassociateCategory(cat, obj);
    assertCleanConstruction();
}
Also used : SubClass(pcgen.core.SubClass) SubClassCategory(pcgen.cdom.enumeration.SubClassCategory) Test(org.junit.Test)

Example 10 with SubClass

use of pcgen.core.SubClass in project pcgen by PCGen.

the class FavoredClassTokenTest method testRoundRobinThreeSub.

@Test
public void testRoundRobinThreeSub() throws PersistenceLayerException {
    construct(primaryContext, "TestWP1");
    construct(primaryContext, "TestWP2");
    construct(primaryContext, "TestWP3");
    construct(secondaryContext, "TestWP1");
    construct(secondaryContext, "TestWP2");
    construct(secondaryContext, "TestWP3");
    SubClass obj = primaryContext.getReferenceContext().constructCDOMObject(SubClass.class, "Sub");
    SubClassCategory cat = SubClassCategory.getConstant("TestWP2");
    primaryContext.getReferenceContext().reassociateCategory(cat, obj);
    obj = secondaryContext.getReferenceContext().constructCDOMObject(SubClass.class, "Sub");
    secondaryContext.getReferenceContext().reassociateCategory(cat, obj);
    runRoundRobin("TestWP1" + getJoinCharacter() + "TestWP2.Sub" + getJoinCharacter() + "TestWP3");
}
Also used : SubClass(pcgen.core.SubClass) SubClassCategory(pcgen.cdom.enumeration.SubClassCategory) Test(org.junit.Test)

Aggregations

SubClass (pcgen.core.SubClass)21 SubClassCategory (pcgen.cdom.enumeration.SubClassCategory)11 Test (org.junit.Test)9 PCClass (pcgen.core.PCClass)8 ArrayList (java.util.ArrayList)3 ClassSkillList (pcgen.cdom.list.ClassSkillList)3 SubstitutionClass (pcgen.core.SubstitutionClass)3 StringTokenizer (java.util.StringTokenizer)2 SpellProhibitor (pcgen.core.SpellProhibitor)2 CDOMObject (pcgen.cdom.base.CDOMObject)1 CDOMReference (pcgen.cdom.base.CDOMReference)1 HitDie (pcgen.cdom.content.HitDie)1 PCClassLevel (pcgen.cdom.inst.PCClassLevel)1 ClassSpellList (pcgen.cdom.list.ClassSpellList)1 DomainSpellList (pcgen.cdom.list.DomainSpellList)1 CategorizedCDOMReference (pcgen.cdom.reference.CategorizedCDOMReference)1 Domain (pcgen.core.Domain)1 PCTemplate (pcgen.core.PCTemplate)1 CDOMChooserFacadeImpl (pcgen.core.chooser.CDOMChooserFacadeImpl)1 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)1