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