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);
}
}
}
}
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();
}
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();
}
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");
}
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();
}
Aggregations