use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class AbstractListContext method commit.
void commit() {
ListCommitStrategy commit = getCommitStrategy();
for (CDOMReference<? extends CDOMList<?>> list : edits.positiveMasterMap.getKeySet()) {
//Note: Intentional Generics Violation due to Sun Compiler
commitDirect((CDOMReference) list);
}
for (CDOMReference<? extends CDOMList<?>> list : edits.negativeMasterMap.getKeySet()) {
//Note: Intentional Generics Violation due to Sun Compiler
removeDirect((CDOMReference) list);
}
for (URI uri : edits.globalClearSet.getKeySet()) {
for (CDOMObject owner : edits.globalClearSet.getSecondaryKeySet(uri)) {
for (String tokenName : edits.globalClearSet.getTertiaryKeySet(uri, owner)) {
for (CDOMReference<? extends CDOMList<?>> list : edits.globalClearSet.getListFor(uri, owner, tokenName)) {
commit.removeAllFromList(tokenName, owner, list);
}
}
}
}
for (URI uri : edits.negativeMap.getKeySet()) {
for (CDOMObject owner : edits.negativeMap.getSecondaryKeySet(uri)) {
CDOMObject neg = edits.negativeMap.get(uri, owner);
Collection<CDOMReference<? extends CDOMList<?>>> modifiedLists = neg.getModifiedLists();
for (CDOMReference<? extends CDOMList<?>> list : modifiedLists) {
//Note: Intentional Generics Violation due to Sun Compiler
remove(owner, neg, (CDOMReference) list);
}
}
}
for (URI uri : edits.positiveMap.getKeySet()) {
for (CDOMObject owner : edits.positiveMap.getSecondaryKeySet(uri)) {
CDOMObject neg = edits.positiveMap.get(uri, owner);
Collection<CDOMReference<? extends CDOMList<?>>> modifiedLists = neg.getModifiedLists();
for (CDOMReference<? extends CDOMList<?>> list : modifiedLists) {
//Note: Intentional Generics Violation due to Sun Compiler
add(owner, neg, (CDOMReference) list);
}
}
}
for (String token : edits.masterAllClear.getKeySet()) {
for (OwnerURI ou : edits.masterAllClear.getListFor(token)) {
commit.clearAllMasterLists(token, ou.owner);
}
}
rollback();
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class SpellsFacet method dataAdded.
/**
* Adds a SpellLikeAbility to this facet if the CDOMObject added to a Player
* Character contains a SPELLS entry.
*
* Triggered when one of the Facets to which SpellsFacet 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) {
CharID id = dfce.getCharID();
CDOMObject cdo = dfce.getCDOMObject();
Collection<CDOMReference<Spell>> mods = cdo.getListMods(Spell.SPELLS);
if (mods == null) {
return;
}
for (CDOMReference<Spell> ref : mods) {
Collection<AssociatedPrereqObject> assocs = cdo.getListAssociations(Spell.SPELLS, ref);
Collection<Spell> spells = ref.getContainedObjects();
for (AssociatedPrereqObject apo : assocs) {
Formula times = apo.getAssociation(AssociationKey.TIMES_PER_UNIT);
String timeunit = apo.getAssociation(AssociationKey.TIME_UNIT);
// The timeunit needs to default to day as per the docs
if (timeunit == null) {
timeunit = "Day";
}
String casterlevel = apo.getAssociation(AssociationKey.CASTER_LEVEL);
String dcformula = apo.getAssociation(AssociationKey.DC_FORMULA);
String book = apo.getAssociation(AssociationKey.SPELLBOOK);
String ident = cdo.getQualifiedKey();
for (Spell sp : spells) {
SpellLikeAbility sla = new SpellLikeAbility(sp, times, timeunit, book, casterlevel, dcformula, ident);
sla.addAllPrerequisites(apo.getPrerequisiteList());
add(id, sla, cdo);
}
}
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class StartingLanguageFacet method dataAdded.
/**
* Adds available Languages to this facet when a CDOMObject added to a
* Player Character makes Languages available to the Player Character.
*
* Triggered when one of the Facets to which StartingLanguageFacet 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<Language>> list = cdo.getListMods(Language.STARTING_LIST);
if (list != null) {
CharID id = dfce.getCharID();
for (CDOMReference<Language> ref : list) {
addAll(id, ref.getContainedObjects(), cdo);
}
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class KnownSpellInputFacet method dataAdded.
/**
* Triggered when one of the Facets to which ConditionallyKnownSpellFacet
* 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<? extends CDOMList<?>>> listrefs = cdo.getModifiedLists();
CharID id = dfce.getCharID();
for (CDOMReference<? extends CDOMList<?>> ref : listrefs) {
processListRef(id, cdo, ref);
}
}
use of pcgen.cdom.base.CDOMObject in project pcgen by PCGen.
the class ModifierFacet method dataRemoved.
/**
* Triggered when one of the Facets to which ModifierFacet listens fires a
* DataFacetChangeEvent to indicate a CDOMObject was removed from a Player
* Character.
*
* Long term this method needs to be symmetric with dataAdded.
*
* @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 dataRemoved(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
CharID id = dfce.getCharID();
CDOMObject obj = dfce.getCDOMObject();
List<VarModifier<?>> modifiers = obj.getListFor(ListKey.MODIFY);
if (modifiers != null) {
ScopeInstance inst = scopeFacet.get(id, obj);
for (VarModifier<?> vm : modifiers) {
processRemoval(id, obj, vm, inst);
}
}
if (obj instanceof Equipment) {
Equipment equip = (Equipment) obj;
for (EquipmentHead head : equip.getEquipmentHeads()) {
ScopeInstance inst = scopeFacet.get(id, head);
modifiers = head.getListFor(ListKey.MODIFY);
if (modifiers != null) {
for (VarModifier<?> vm : modifiers) {
processRemoval(id, equip, vm, inst);
}
}
}
}
}
Aggregations