Search in sources :

Example 86 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class ClassSkillsTokenTest method testUnparseSingleRanked.

@Test
public void testUnparseSingleRanked() throws PersistenceLayerException {
    List<CDOMReference<Skill>> refs = new ArrayList<>();
    addSingleRef(refs, "TestWP1");
    ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<>(refs);
    ChoiceSet<Skill> cs = new ChoiceSet<>(getSubToken().getTokenName(), rcs);
    PersistentTransitionChoice<Skill> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.ONE);
    primaryProf.addToListFor(ListKey.ADD, tc);
    tc.setChoiceActor(new ClassSkillChoiceActor(fighter, 3));
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, getSubTokenName() + '|' + "TestWP1,AUTORANK=3");
}
Also used : ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ChoiceSet(pcgen.cdom.base.ChoiceSet) ArrayList(java.util.ArrayList) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) Skill(pcgen.core.Skill) ClassSkillChoiceActor(pcgen.cdom.helper.ClassSkillChoiceActor) CDOMReference(pcgen.cdom.base.CDOMReference) ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) Test(org.junit.Test)

Example 87 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class AbilityTokenTest method testUnparseComplex.

@Test
public void testUnparseComplex() throws PersistenceLayerException {
    List<CDOMReference<Ability>> refs = createSingle("TestWP1");
    AbilityRefChoiceSet rcs = new AbilityRefChoiceSet(CDOMDirectSingleRef.getRef(AbilityCategory.FEAT), refs, Nature.VIRTUAL);
    assert (rcs.getGroupingState().isValid());
    AbilityChoiceSet cs = new AbilityChoiceSet(getSubToken().getTokenName(), rcs);
    cs.setTitle("Virtual Feat Selection");
    PersistentTransitionChoice<CNAbilitySelection> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.getFormulaFor(3));
    tc.allowStack(true);
    tc.setStackLimit(2);
    tc.setChoiceActor(subtoken);
    primaryProf.addToListFor(ListKey.ADD, tc);
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, getSubTokenName() + '|' + "3|FEAT|VIRTUAL|STACKS=2,TestWP1");
}
Also used : AbilityChoiceSet(pcgen.cdom.base.ChoiceSet.AbilityChoiceSet) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) CDOMReference(pcgen.cdom.base.CDOMReference) AbilityRefChoiceSet(pcgen.cdom.choiceset.AbilityRefChoiceSet) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) Test(org.junit.Test)

Example 88 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class ShieldProfTokenTest method loadProf.

@Override
protected void loadProf(CDOMSingleRef<ShieldProf> ref) {
    List<CDOMReference<ShieldProf>> shieldProfs = new ArrayList<>();
    List<CDOMReference<Equipment>> equipTypes = new ArrayList<>();
    shieldProfs.add(ref);
    ShieldProfProvider pp = new ShieldProfProvider(shieldProfs, equipTypes);
    primaryProf.addToListFor(ListKey.AUTO_SHIELDPROF, pp);
}
Also used : ArrayList(java.util.ArrayList) ShieldProfProvider(pcgen.cdom.helper.ShieldProfProvider) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 89 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class AddedTemplateFacet method dataRemoved.

/**
	 * Adds and removes (as appropriate - opposite of the action defined in the
	 * LST files) the PCTemplates associated with a CDOMObject which is removed
	 * from a Player Character.
	 * 
	 * Triggered when one of the Facets to which AddedTemplateFacet listens
	 * fires a DataFacetChangeEvent to indicate a CDOMObject was removed from 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 dataRemoved(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
    CDOMObject cdo = dfce.getCDOMObject();
    CharID id = dfce.getCharID();
    PlayerCharacter pc = trackingFacet.getPC(id);
    Collection<PCTemplate> list = getFromSource(id, cdo);
    if (list != null) {
        for (PCTemplate pct : list) {
            pc.removeTemplate(pct);
        }
    }
    removeAll(id, cdo);
    Collection<CDOMReference<PCTemplate>> refList = cdo.getListFor(ListKey.TEMPLATE);
    if (refList != null) {
        for (CDOMReference<PCTemplate> pctr : refList) {
            for (PCTemplate pct : pctr.getContainedObjects()) {
                pc.removeTemplate(pct);
            }
        }
    }
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) CDOMObject(pcgen.cdom.base.CDOMObject) PCTemplate(pcgen.core.PCTemplate) CharID(pcgen.cdom.enumeration.CharID) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 90 with CDOMReference

use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.

the class AutoEquipmentFacet method getAutoEquipment.

/**
	 * Returns a List of Equipment granted to the Player Character by all
	 * AUTO:EQUIPMENT tokens on objects added to the Player Character.
	 * 
	 * This method is value-semantic in that ownership of the returned List is
	 * transferred to the class calling this method. Modification of the
	 * returned List will not modify this AutoEquipmentFacet and modification of
	 * this AutoEquipmentFacet will not modify the returned Collection.
	 * Modifications to the returned List will also not modify any future or
	 * previous objects returned by this (or other) methods on
	 * AutoEquipmentFacet. If you wish to modify the information stored in this
	 * AutoEquipmentFacet, you must use the add*() and remove*() methods of
	 * AutoEquipmentFacet.
	 * 
	 * @param id
	 *            The CharID identifying the Player Character for which the list
	 *            of all equipment granted by AUTO:EQUIP will be returned.
	 * @return The List of Equipment granted by the Player Character by all
	 *         AUTO:EQUIP tokens on objects added to the Player Character.
	 */
public List<Equipment> getAutoEquipment(CharID id) {
    List<Equipment> list = new ArrayList<>();
    for (QualifiedObject<CDOMReference<Equipment>> qo : getQualifiedSet(id)) {
        Collection<Equipment> equipList = qo.getRawObject().getContainedObjects();
        for (Equipment e : equipList) {
            e = e.clone();
            e.setQty(1);
            e.setAutomatic(true);
            list.add(e);
        }
    }
    return list;
}
Also used : Equipment(pcgen.core.Equipment) ArrayList(java.util.ArrayList) CDOMReference(pcgen.cdom.base.CDOMReference)

Aggregations

CDOMReference (pcgen.cdom.base.CDOMReference)125 ArrayList (java.util.ArrayList)57 StringTokenizer (java.util.StringTokenizer)40 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)35 ParseResult (pcgen.rules.persistence.token.ParseResult)30 Skill (pcgen.core.Skill)24 ChoiceSet (pcgen.cdom.base.ChoiceSet)22 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)21 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)19 Prerequisite (pcgen.core.prereq.Prerequisite)18 Formula (pcgen.base.formula.Formula)16 CDOMObject (pcgen.cdom.base.CDOMObject)15 Spell (pcgen.core.spell.Spell)15 TreeSet (java.util.TreeSet)14 Test (org.junit.Test)14 ClassSkillChoiceActor (pcgen.cdom.helper.ClassSkillChoiceActor)12 CharID (pcgen.cdom.enumeration.CharID)11 ObjectMatchingReference (pcgen.cdom.reference.ObjectMatchingReference)11 ParsingSeparator (pcgen.base.text.ParsingSeparator)10 CDOMList (pcgen.cdom.base.CDOMList)10