use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class ClassSkillsTokenTest method testUnparseTrained.
@Test
public void testUnparseTrained() throws PersistenceLayerException {
List<CDOMReference<Skill>> refs = new ArrayList<>();
ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<>("TRAINED", Skill.class, getAllRef(), ObjectKey.USE_UNTRAINED, Boolean.FALSE);
omr.returnIncludesNulls(true);
refs.add(omr);
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, null));
String[] unparsed = getToken().unparse(primaryContext, primaryProf);
expectSingle(unparsed, getSubTokenName() + '|' + "TRAINED");
}
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);
}
}
}
}
Aggregations