use of pcgen.cdom.base.AssociatedPrereqObject in project pcgen by PCGen.
the class DeityToken method getCollection.
@Override
public <R> Collection<R> getCollection(PlayerCharacter pc, Converter<Domain, R> c) {
HashSet<R> returnSet = new HashSet<>();
Deity deity = pc.getDisplay().getDeity();
if (deity == null) {
return returnSet;
}
CDOMReference<DomainList> list = Deity.DOMAINLIST;
Collection<CDOMReference<Domain>> mods = deity.getListMods(list);
for (CDOMReference<Domain> ref : mods) {
Collection<AssociatedPrereqObject> assoc = deity.getListAssociations(list, ref);
for (AssociatedPrereqObject apo : assoc) {
if (PrereqHandler.passesAll(apo.getPrerequisiteList(), pc, deity)) {
returnSet.addAll(c.convert(ref));
break;
}
}
}
return returnSet;
}
use of pcgen.cdom.base.AssociatedPrereqObject 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.AssociatedPrereqObject 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.AssociatedPrereqObject 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.AssociatedPrereqObject 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