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");
}
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");
}
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);
}
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);
}
}
}
}
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;
}
Aggregations