Search in sources :

Example 36 with CDOMObject

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);
                        }
                    }
                }
            }
        }
    }
}
Also used : ScopeInstance(pcgen.base.formula.base.ScopeInstance) EquipmentHead(pcgen.cdom.inst.EquipmentHead) Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject) RemoteModifier(pcgen.cdom.content.RemoteModifier) VarScoped(pcgen.base.formula.base.VarScoped) CharID(pcgen.cdom.enumeration.CharID)

Example 37 with CDOMObject

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);
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) ShieldProfProvider(pcgen.cdom.helper.ShieldProfProvider)

Example 38 with CDOMObject

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);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) CDOMObject(pcgen.cdom.base.CDOMObject)

Example 39 with CDOMObject

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);
                        }
                    }
                }
            }
        }
    }
}
Also used : ScopeInstance(pcgen.base.formula.base.ScopeInstance) EquipmentHead(pcgen.cdom.inst.EquipmentHead) Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject) RemoteModifier(pcgen.cdom.content.RemoteModifier) VarScoped(pcgen.base.formula.base.VarScoped) CharID(pcgen.cdom.enumeration.CharID)

Example 40 with CDOMObject

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);
        }
    }
}
Also used : Equipment(pcgen.core.Equipment) CDOMObject(pcgen.cdom.base.CDOMObject) CharID(pcgen.cdom.enumeration.CharID)

Aggregations

CDOMObject (pcgen.cdom.base.CDOMObject)235 Test (org.junit.Test)68 CharID (pcgen.cdom.enumeration.CharID)53 PCTemplate (pcgen.core.PCTemplate)30 ArrayList (java.util.ArrayList)22 PCClass (pcgen.core.PCClass)18 DataFacetChangeEvent (pcgen.cdom.facet.event.DataFacetChangeEvent)17 Race (pcgen.core.Race)17 Equipment (pcgen.core.Equipment)15 PlayerCharacter (pcgen.core.PlayerCharacter)15 Map (java.util.Map)14 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)14 CDOMReference (pcgen.cdom.base.CDOMReference)14 BonusObj (pcgen.core.bonus.BonusObj)14 IdentityHashMap (java.util.IdentityHashMap)12 Set (java.util.Set)12 VariableKey (pcgen.cdom.enumeration.VariableKey)11 HashMap (java.util.HashMap)10 CNAbility (pcgen.cdom.content.CNAbility)10 Spell (pcgen.core.spell.Spell)9