use of pcgen.cdom.helper.ArmorProfProvider in project pcgen by PCGen.
the class ArmorProfFacet method dataAdded.
/**
* Processes added CDOMObjects to determine whether they contained an
* AUTO:ARMORPROF, and if so, processes the contents of that token to add
* the appropriate ArmorProfProviders to the Player Character.
*
* Triggered when one of the Facets to which ArmorProfFacet listens fires a
* DataFacetChangeEvent to indicate a CDOMObject was added to a Player
* Character.
*
* @param dfce
* The DataFacetChangeEvent containing the information about the
* change
*
* @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
*/
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
CDOMObject cdo = dfce.getCDOMObject();
List<ArmorProfProvider> armorProfs = cdo.getListFor(ListKey.AUTO_ARMORPROF);
if (armorProfs != null) {
armorProfProviderFacet.addAll(dfce.getCharID(), armorProfs, cdo);
}
}
use of pcgen.cdom.helper.ArmorProfProvider in project pcgen by PCGen.
the class ArmorProfToken method unparse.
@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
Changes<ArmorProfProvider> changes = context.getObjectContext().getListChanges(obj, ListKey.AUTO_ARMORPROF);
Changes<ChooseSelectionActor<?>> listChanges = context.getObjectContext().getListChanges(obj, ListKey.NEW_CHOOSE_ACTOR);
Collection<ArmorProfProvider> added = changes.getAdded();
Set<String> set = new TreeSet<>();
Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
boolean foundAny = false;
boolean foundOther = false;
if (listAdded != null && !listAdded.isEmpty()) {
for (ChooseSelectionActor<?> cra : listAdded) {
if (cra.getSource().equals(getTokenName())) {
try {
set.add(cra.getLstFormat());
foundOther = true;
} catch (PersistenceLayerException e) {
context.addWriteMessage("Error writing Prerequisite: " + e);
return null;
}
}
}
}
if (added != null) {
for (ArmorProfProvider spp : added) {
StringBuilder sb = new StringBuilder();
sb.append(spp.getLstFormat());
if (spp.hasPrerequisites()) {
sb.append('|');
sb.append(getPrerequisiteString(context, spp.getPrerequisiteList()));
}
String ab = sb.toString();
boolean isUnconditionalAll = Constants.LST_ALL.equals(ab);
foundAny |= isUnconditionalAll;
foundOther |= !isUnconditionalAll;
set.add(ab);
}
}
if (foundAny && foundOther) {
context.addWriteMessage("Non-sensical " + getFullName() + ": Contains ANY and a specific reference: " + set);
return null;
}
if (set.isEmpty()) {
//okay
return null;
}
return set.toArray(new String[set.size()]);
}
Aggregations