use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class VisionFacet method dataAdded.
/**
* Adds any granted Vision objects to this facet when a CDOMObject that
* grants Vision objects is added to a Player Character.
*
* Triggered when one of the Facets to which VisionFacet 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();
Collection<CDOMReference<Vision>> mods = cdo.getListMods(Vision.VISIONLIST);
if (mods != null) {
CharID id = dfce.getCharID();
for (CDOMReference<Vision> ref : mods) {
Collection<AssociatedPrereqObject> assoc = cdo.getListAssociations(Vision.VISIONLIST, ref);
for (AssociatedPrereqObject apo : assoc) {
List<Prerequisite> prereqs = apo.getPrerequisiteList();
for (Vision v : ref.getContainedObjects()) {
add(id, new QualifiedObject<>(v, prereqs), cdo);
}
}
}
}
}
use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class AbstractProfProvider method providesEquipmentType.
/**
* Returns true if this AbstractProfProvider provides proficiency with the
* given Equipment TYPE. This only tests against the Equipment TYPE
* reference list provided during construction of the AbstractProfProvider.
*
* @param typeString
* The TYPE of Equipment to be tested to see if this
* AbstractProfProvider provides proficiency with the given
* Equipment TYPE
* @return true if this AbstractProfProvider provides proficiency with the
* given Equipment TYPE.
*/
@Override
@SuppressWarnings("PMD.AvoidBranchingStatementAsLastInLoop")
public boolean providesEquipmentType(String typeString) {
if (typeString == null || typeString.isEmpty()) {
return false;
}
Set<String> types = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
Collections.addAll(types, typeString.split("\\."));
REF: for (CDOMReference<Equipment> ref : byEquipType) {
StringTokenizer tok = new StringTokenizer(ref.getLSTformat(false).substring(5), ".");
while (tok.hasMoreTokens()) {
if (!types.contains(tok.nextToken())) {
continue REF;
}
}
return true;
}
return false;
}
use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class ListChanges method getAddedAssociations.
@Override
public MapToList<CDOMReference<T>, AssociatedPrereqObject> getAddedAssociations() {
Collection<CDOMReference<T>> mods = positive.getListMods(list);
if (mods == null) {
return null;
}
MapToList<CDOMReference<T>, AssociatedPrereqObject> owned = new TreeMapToList<>(ReferenceUtilities.REFERENCE_SORTER);
for (CDOMReference<T> lw : mods) {
Collection<AssociatedPrereqObject> assocs = positive.getListAssociations(list, lw);
for (AssociatedPrereqObject assoc : assocs) {
if (tokenName.equals(assoc.getAssociation(AssociationKey.TOKEN))) {
owned.addToListFor(lw, assoc);
}
}
}
if (owned.isEmpty()) {
return null;
}
return owned;
}
use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class AbstractListContext method add.
private <BT extends CDOMObject, L extends CDOMList<BT>> void add(CDOMObject owner, CDOMObject neg, CDOMReference<L> list) {
ListCommitStrategy commit = getCommitStrategy();
Collection<CDOMReference<BT>> mods = neg.getListMods(list);
for (CDOMReference<BT> ref : mods) {
for (AssociatedPrereqObject assoc : neg.getListAssociations(list, ref)) {
String token = assoc.getAssociation(AssociationKey.TOKEN);
AssociatedPrereqObject edge = commit.addToList(token, owner, list, ref);
Collection<AssociationKey<?>> associationKeys = assoc.getAssociationKeys();
for (AssociationKey<?> ak : associationKeys) {
setAssoc(assoc, edge, ak);
}
edge.addAllPrerequisites(assoc.getPrerequisiteList());
}
}
}
use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class AbstractListContext method cloneInMasterLists.
/**
* Create a copy of any associations to the original object and link them
* to the new object. This will scan lists such as ClassSpellLists and
* DomainSpellLists which may link to the original object. For each
* association found, a new association will be created linking to the new object
* and the association will be added to the list.
*
* @param <T> The type of CDOMObject being copied (e.g. Spell, Domain etc)
* @param cdoOld The original object being copied.
* @param cdoNew The new object to be linked in.
*/
@SuppressWarnings("unchecked")
<T extends CDOMObject> void cloneInMasterLists(T cdoOld, T cdoNew) {
MasterListInterface masterLists = SettingsHandler.getGame().getMasterLists();
for (CDOMReference ref : masterLists.getActiveLists()) {
Collection<AssociatedPrereqObject> assocs = masterLists.getAssociations(ref, cdoOld);
if (assocs != null) {
for (AssociatedPrereqObject apo : assocs) {
// Logging.debugPrint("Found assoc from " + ref + " to "
// + apo.getAssociationKeys() + " / "
// + apo.getAssociation(AssociationKey.OWNER));
AssociatedPrereqObject newapo = getCommitStrategy().addToMasterList(apo.getAssociation(AssociationKey.TOKEN), cdoNew, ref, cdoNew);
newapo.addAllPrerequisites(apo.getPrerequisiteList());
for (AssociationKey assocKey : apo.getAssociationKeys()) {
if (assocKey != AssociationKey.TOKEN && assocKey != AssociationKey.OWNER) {
newapo.setAssociation(assocKey, apo.getAssociation(assocKey));
}
}
}
}
}
}
Aggregations