Search in sources :

Example 1 with SubClassCategory

use of pcgen.cdom.enumeration.SubClassCategory 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 2 with SubClassCategory

use of pcgen.cdom.enumeration.SubClassCategory 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 3 with SubClassCategory

use of pcgen.cdom.enumeration.SubClassCategory 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 4 with SubClassCategory

use of pcgen.cdom.enumeration.SubClassCategory 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)

Example 5 with SubClassCategory

use of pcgen.cdom.enumeration.SubClassCategory 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)

Aggregations

SubClassCategory (pcgen.cdom.enumeration.SubClassCategory)14 SubClass (pcgen.core.SubClass)11 Test (org.junit.Test)9 PCClass (pcgen.core.PCClass)4 StringTokenizer (java.util.StringTokenizer)3 CDOMReference (pcgen.cdom.base.CDOMReference)3 CategorizedCDOMReference (pcgen.cdom.reference.CategorizedCDOMReference)3 ParseResult (pcgen.rules.persistence.token.ParseResult)2 ArrayList (java.util.ArrayList)1 ClassSkillList (pcgen.cdom.list.ClassSkillList)1 ClassSpellList (pcgen.cdom.list.ClassSpellList)1 DomainSpellList (pcgen.cdom.list.DomainSpellList)1 Domain (pcgen.core.Domain)1 PCTemplate (pcgen.core.PCTemplate)1 LoadContext (pcgen.rules.context.LoadContext)1 TestContext (plugin.lsttokens.editcontext.testsupport.TestContext)1