use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class RemoteModifierFacet method dataAdded.
@Override
public void dataAdded(DataFacetChangeEvent<CharID, VarScoped> dfce) {
CharID id = dfce.getCharID();
VarScoped vs = dfce.getCDOMObject();
/*
* If this can have local variables, find what may have been modified by
* previous objects
*/
for (RemoteModifier<?> rm : getSet(id)) {
VarScoped src = get(id, rm);
ScopeInstance inst = scopeFacet.get(id, src);
processAdd(id, rm, vs, inst);
if (vs instanceof Equipment) {
Equipment e = (Equipment) vs;
for (EquipmentHead head : e.getEquipmentHeads()) {
processAdd(id, rm, head, inst);
}
}
}
/*
* Look at what newly added object can modify on others
*/
if (vs instanceof CDOMObject) {
ScopeInstance inst = scopeFacet.get(id, vs);
List<RemoteModifier<?>> list = ((CDOMObject) vs).getListFor(ListKey.REMOTE_MODIFIER);
if (list != null) {
Set<? extends VarScoped> targets = varScopedFacet.getSet(id);
for (RemoteModifier<?> rm : list) {
set(id, rm, vs);
//Apply to existing as necessary
for (VarScoped obj : targets) {
processAdd(id, rm, obj, inst);
if (obj instanceof Equipment) {
Equipment e = (Equipment) obj;
for (EquipmentHead head : e.getEquipmentHeads()) {
processAdd(id, rm, head, inst);
}
}
}
}
}
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class ShieldProfFacet method dataAdded.
/**
* Processes added CDOMObjects to determine whether they contained an
* AUTO:SHIELDPROF, and if so, processes the contents of that token to add
* the appropriate ShieldProfProviders to the Player Character.
*
* Triggered when one of the Facets to which ShieldProfFacet 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<ShieldProfProvider> shieldProfs = cdo.getListFor(ListKey.AUTO_SHIELDPROF);
if (shieldProfs != null) {
shieldProfProviderFacet.addAll(dfce.getCharID(), shieldProfs, cdo);
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class PrerequisiteFacet method qualifies.
/**
* Returns true if the Player Character identified by the given CharID
* qualifies for the given QualifyingObject when the QualifyingObject is
* from the given source.
*
* @param id
* The CharID identifying the Player Character on which the
* prerequisite test will be performed
* @param obj
* The QualifyingObject which contains the prerequisite(s) to be
* tested
* @param source
* The source of the QualifyingObject, which is used to given
* context to the prerequisites being tested
* @return true if the Player Character identified by the given CharID
* qualifies for the given QualifyingObject when the
* QualifyingObject is from the given source; false otherwise
*/
public boolean qualifies(CharID id, QualifyingObject obj, Object source) {
PlayerCharacter pc = trackingFacet.getPC(id);
CDOMObject cdo = null;
if (source instanceof CDOMObject) {
cdo = (CDOMObject) source;
}
return obj.qualifies(pc, cdo);
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class RemoteModifierFacet method dataRemoved.
@Override
public void dataRemoved(DataFacetChangeEvent<CharID, VarScoped> dfce) {
CharID id = dfce.getCharID();
VarScoped vs = dfce.getCDOMObject();
/*
* If this can have local variables, find what had been modified by
* previous objects
*/
for (RemoteModifier<?> rm : getSet(id)) {
VarScoped src = get(id, rm);
ScopeInstance inst = scopeFacet.get(id, src);
processRemove(id, rm, vs, inst);
if (vs instanceof Equipment) {
Equipment e = (Equipment) vs;
for (EquipmentHead head : e.getEquipmentHeads()) {
processRemove(id, rm, head, inst);
}
}
}
/*
* Look at what newly added object can modify on others
*/
if (vs instanceof CDOMObject) {
ScopeInstance inst = scopeFacet.get(id, vs);
List<RemoteModifier<?>> list = ((CDOMObject) vs).getListFor(ListKey.REMOTE_MODIFIER);
if (list != null) {
Set<? extends VarScoped> targets = varScopedFacet.getSet(id);
for (RemoteModifier<?> rm : list) {
remove(id, rm);
//RemoveFrom existing as necessary
for (VarScoped obj : targets) {
processRemove(id, rm, obj, inst);
if (obj instanceof Equipment) {
Equipment e = (Equipment) obj;
for (EquipmentHead head : e.getEquipmentHeads()) {
processRemove(id, rm, head, inst);
}
}
}
}
}
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class NaturalWeaponFacet method dataAdded.
/**
* Adds any Natural Attacks (TYPE=Natural Equipment) which are granted by a
* CDOMObject which was added to a Player Character.
*
* Triggered when one of the Facets to which NaturalWeaponFacet 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<Equipment> weapons = cdo.getListFor(ListKey.NATURAL_WEAPON);
if (weapons != null) {
CharID id = dfce.getCharID();
for (Equipment e : weapons) {
add(id, e, cdo);
}
}
}
Aggregations