use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class FollowerOptionFacet method getAvailableFollowers.
/**
* Returns a non-null copy of the available FollowerOptions of a given type
* for the Player Character represented by the given CharID. This method
* returns an empty Map if no objects are in this FollowerOptionFacet for
* the Player Character identified by the given CharID.
*
* This method is value-semantic in that ownership of the returned Map is
* transferred to the class calling this method. Modification of the
* returned Map will not modify this FollowerOptionFacet and modification of
* this FollowerOptionFacet will not modify the returned Map. Modifications
* to the returned Set will also not modify any future or previous objects
* returned by this (or other) methods on FollowerOptionFacet. If you wish
* to modify the information stored in this FollowerOptionFacet, you must
* use the add*() and remove*() methods of FollowerOptionFacet.
*
* @param id
* The CharID representing the Player Character for which the
* items in this FollowerOptionFacet should be returned
* @param type
* The type of FollowerOption that should be returned
* @param comp
* An optional Comparator to be used to sort the FollowerOption
* objects in the returned Map. null is a legal value, and will
* result in the FollowerOptions being sorted by their type
* @return A non-null copy of the Map of FollowerOptions in this
* FollowerOptionFacet for the Player Character represented by the
* given CharID
*/
public Map<FollowerOption, CDOMObject> getAvailableFollowers(CharID id, String type, Comparator<FollowerOption> comp) {
CaseInsensitiveMap<Map<FollowerOption, Set<CDOMObject>>> componentMap = getCachedMap(id);
if (componentMap == null) {
return Collections.emptyMap();
}
Map<FollowerOption, Set<CDOMObject>> foMap = componentMap.get(type);
if (foMap == null) {
return Collections.emptyMap();
}
Map<FollowerOption, CDOMObject> ret = new TreeMap<>(comp);
for (Map.Entry<FollowerOption, Set<CDOMObject>> me : foMap.entrySet()) {
FollowerOption fo = me.getKey();
Set<CDOMObject> target = me.getValue();
Collection<FollowerOption> expanded = fo.getExpandedOptions();
for (CDOMObject source : target) {
for (FollowerOption efo : expanded) {
/*
* TODO This is a bug, and will overwrite the first source
* :(
*/
ret.put(efo, source);
}
}
}
return ret;
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class GlobalSkillCostFacet method dataAdded.
/**
* Adds the SkillCost objects granted by CDOMObjects added to the Player
* Character to this GlobalSkillCostFacet.
*
* Triggered when one of the Facets to which GlobalSkillCostFacet 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();
CharID id = dfce.getCharID();
for (CDOMReference<Skill> ref : cdo.getSafeListFor(ListKey.CSKILL)) {
for (Skill sk : ref.getContainedObjects()) {
add(id, SkillCost.CLASS, sk, cdo);
}
}
for (CDOMReference<Skill> ref : cdo.getSafeListFor(ListKey.CCSKILL)) {
for (Skill sk : ref.getContainedObjects()) {
add(id, SkillCost.CROSS_CLASS, sk, cdo);
}
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class HasAnyFavoredClassFacet method dataAdded.
/**
* Adds the Any Favored Class capability granted by CDOMObjects added to the
* Player Character to this HasAnyFavoredClassFacet.
*
* Triggered when one of the Facets to which HasAnyFavoredClassFacet 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();
Boolean hdw = cdo.get(ObjectKey.ANY_FAVORED_CLASS);
if (hdw != null) {
add(dfce.getCharID(), hdw, cdo);
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class SpecialAbilityFacet method dataAdded.
/**
* Extracts SpecialAbility objects from CDOMObjects granted to a Player
* Character. The SpecialAbility objects are granted to the Player
* Character.
*
* Triggered when one of the Facets to which SpecialAbilityFacet 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();
addAll(dfce.getCharID(), cdo.getSafeListFor(ListKey.SAB), cdo);
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class StatLockFacet method dataAdded.
/**
* Adds StatLock objects granted by a CDOMObject which has been added to a
* Player Character.
*
* Triggered when one of the Facets to which StatLockFacet 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<StatLock> locks = cdo.getListFor(ListKey.STAT_LOCKS);
if (locks != null) {
addAll(dfce.getCharID(), locks, cdo);
}
}
Aggregations