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 MoncskillToken method unparse.
@Override
public String[] unparse(LoadContext context, Race race) {
CDOMGroupRef<ClassSkillList> monsterList = context.getReferenceContext().getCDOMTypeReference(ClassSkillList.class, "Monster");
AssociatedChanges<CDOMReference<Skill>> changes = context.getListContext().getChangesInList(getTokenName(), race, monsterList);
Changes<ChooseSelectionActor<?>> listChanges = context.getObjectContext().getListChanges(race, ListKey.NEW_CHOOSE_ACTOR);
List<String> list = new ArrayList<>();
Collection<CDOMReference<Skill>> removedItems = changes.getRemoved();
if (removedItems != null && !removedItems.isEmpty()) {
if (changes.includesGlobalClear()) {
context.addWriteMessage("Non-sensical relationship in " + getTokenName() + ": global .CLEAR and local .CLEAR. performed");
return null;
}
list.add(Constants.LST_DOT_CLEAR_DOT + ReferenceUtilities.joinLstFormat(removedItems, "|.CLEAR."));
}
Collection<ChooseSelectionActor<?>> listRemoved = listChanges.getRemoved();
if (listRemoved != null && !listRemoved.isEmpty()) {
if (listRemoved.contains(this)) {
list.add(".CLEAR.LIST");
}
}
if (changes.includesGlobalClear()) {
list.add(Constants.LST_DOT_CLEAR);
}
MapToList<CDOMReference<Skill>, AssociatedPrereqObject> map = changes.getAddedAssociations();
if (map != null && !map.isEmpty()) {
Set<CDOMReference<Skill>> added = map.getKeySet();
for (CDOMReference<Skill> ab : added) {
for (AssociatedPrereqObject assoc : map.getListFor(ab)) {
if (!SkillCost.CLASS.equals(assoc.getAssociation(AssociationKey.SKILL_COST))) {
context.addWriteMessage("Skill Cost must be " + "CLASS for Token " + getTokenName());
return null;
}
}
}
list.add(ReferenceUtilities.joinLstFormat(added, Constants.PIPE));
}
Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
if (listAdded != null && !listAdded.isEmpty()) {
for (ChooseSelectionActor<?> csa : listAdded) {
if (csa.getSource().equals(getTokenName())) {
try {
list.add(csa.getLstFormat());
} catch (PersistenceLayerException e) {
context.addWriteMessage("Error writing Prerequisite: " + e);
return null;
}
}
}
}
if (list.isEmpty()) {
// Zero indicates no add or clear
return null;
}
return list.toArray(new String[list.size()]);
}
Aggregations