use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.
the class LocalSkillCostFacetTest method addCost.
private void addCost(CharID cid, PCClass cl, Skill skill, SkillCost sc) {
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(cid, cl, new Object(), DataFacetChangeEvent.DATA_ADDED);
ListKey<CDOMReference<Skill>> lk;
if (sc.equals(SkillCost.CLASS)) {
lk = ListKey.LOCALCSKILL;
} else if (sc.equals(SkillCost.CROSS_CLASS)) {
lk = ListKey.LOCALCCSKILL;
} else {
fail("Cannot use " + sc);
//useless except to indicate lk is never used
return;
}
cl.removeListFor(ListKey.LOCALCSKILL);
cl.removeListFor(ListKey.LOCALCCSKILL);
cl.addToListFor(lk, CDOMDirectSingleRef.getRef(skill));
getFacet().dataAdded(dfce);
}
use of pcgen.cdom.facet.event.DataFacetChangeEvent in project pcgen by PCGen.
the class LocalSkillCostFacetTest method testAddTwoSources.
@Test
public void testAddTwoSources() {
Skill t1 = getObject();
assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
addCost(id, class1, t1, SkillCost.CLASS);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
assertFalse(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t1));
//No cross pollution
assertFalse(getFacet().contains(altid, class1, SkillCost.CLASS, t1));
//Second add doesn't change anything
PCClassLevel pcl = new PCClassLevel();
pcl.put(ObjectKey.PARENT, class1);
DataFacetChangeEvent<CharID, CDOMObject> dfce = new DataFacetChangeEvent<>(id, pcl, new Object(), DataFacetChangeEvent.DATA_ADDED);
ListKey<CDOMReference<Skill>> lk = ListKey.LOCALCSKILL;
pcl.addToListFor(lk, CDOMDirectSingleRef.getRef(t1));
getFacet().dataAdded(dfce);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
assertFalse(getFacet().contains(id, class1, SkillCost.CROSS_CLASS, t1));
//No cross pollution
assertFalse(getFacet().contains(altid, class1, SkillCost.CLASS, t1));
}
Aggregations