use of pcgen.core.Skill 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.core.Skill in project pcgen by PCGen.
the class GlobalToSkillCostFacet method dataRemoved.
@Override
public void dataRemoved(DataFacetChangeEvent<CharID, PCClass> dfce) {
CharID id = dfce.getCharID();
PCClass cl = dfce.getCDOMObject();
DataSetID dsID = id.getDatasetID();
for (Skill sk : masterUsableSkillFacet.getSet(dsID)) {
remove(id, cl, SkillCost.CROSS_CLASS, sk, masterUsableSkillFacet);
}
for (SkillCost cost : globalSkillCostFacet.getScopes(id)) {
for (Skill sk : globalSkillCostFacet.getSet(id, cost)) {
remove(id, cl, cost, sk, globalSkillCostFacet);
}
}
for (SkillCost cost : globalAddedSkillCostFacet.getScopes(id)) {
for (Skill sk : globalAddedSkillCostFacet.getSet(id, cost)) {
remove(id, cl, cost, sk, globalAddedSkillCostFacet);
}
}
}
use of pcgen.core.Skill in project pcgen by PCGen.
the class GlobalToSkillCostFacet method dataRemoved.
@Override
public void dataRemoved(ScopeFacetChangeEvent<CharID, SkillCost, Skill> dfce) {
CharID id = dfce.getCharID();
SkillCost cost = dfce.getScope();
Skill sk = dfce.getCDOMObject();
Object source = dfce.getSource();
for (PCClass cl : classFacet.getSet(id)) {
remove(id, cl, cost, sk, source);
}
}
use of pcgen.core.Skill in project pcgen by PCGen.
the class GlobalToSkillCostFacet method dataAdded.
@Override
public void dataAdded(DataFacetChangeEvent<CharID, PCClass> dfce) {
CharID id = dfce.getCharID();
PCClass cl = dfce.getCDOMObject();
DataSetID dsID = id.getDatasetID();
for (Skill sk : masterUsableSkillFacet.getSet(dsID)) {
add(id, cl, SkillCost.CROSS_CLASS, sk, masterUsableSkillFacet);
}
for (SkillCost cost : globalSkillCostFacet.getScopes(id)) {
for (Skill sk : globalSkillCostFacet.getSet(id, cost)) {
add(id, cl, cost, sk, globalSkillCostFacet);
}
}
for (SkillCost cost : globalAddedSkillCostFacet.getScopes(id)) {
for (Skill sk : globalAddedSkillCostFacet.getSet(id, cost)) {
add(id, cl, cost, sk, globalAddedSkillCostFacet);
}
}
}
use of pcgen.core.Skill in project pcgen by PCGen.
the class ListSkillCostFacet method dataAdded.
/**
* Adds the SkillCost objects granted by CDOMObjects, as applied directly to
* a ClassSkillList, when a CDOMObject is added to a Player Character.
*
* Triggered when one of the Facets to which ListSkillCostFacet 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 ref : cdo.getModifiedLists()) {
List<ClassSkillList> useList = new ArrayList<>();
for (Object list : ref.getContainedObjects()) {
if (list instanceof ClassSkillList) {
useList.add((ClassSkillList) list);
}
}
if (!useList.isEmpty()) {
Collection<CDOMReference<Skill>> mods = cdo.getListMods(ref);
for (CDOMReference<Skill> skRef : mods) {
for (AssociatedPrereqObject apo : (Iterable<AssociatedPrereqObject>) cdo.getListAssociations(ref, skRef)) {
SkillCost sc = apo.getAssociation(AssociationKey.SKILL_COST);
for (ClassSkillList csl : useList) {
for (Skill skill : skRef.getContainedObjects()) {
add(id, csl, sc, skill, cdo);
}
}
}
}
}
}
}
Aggregations