use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.
the class MonCCSkillTokenTest method setUp.
@Override
public void setUp() throws PersistenceLayerException, URISyntaxException {
super.setUp();
ClassSkillList a = primaryContext.getReferenceContext().constructCDOMObject(ClassSkillList.class, "Scary Monster");
a.addType(Type.MONSTER);
ClassSkillList b = secondaryContext.getReferenceContext().constructCDOMObject(ClassSkillList.class, "Scary Monster");
b.addType(Type.MONSTER);
}
use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.
the class RaceMonCCSkillTest method testDirect.
@Test
public void testDirect() throws PersistenceLayerException {
Race source = create(Race.class, "Source");
ParseResult result = token.parseToken(context, source, "MySkill");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
new ExclusiveToken().parseToken(context, sk, "Yes");
finishLoad();
assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(sk, dragon));
raceFacet.directSet(id, source, getAssoc());
ClassSkillList dragonCSL = context.getReferenceContext().silentlyGetConstructedCDOMObject(ClassSkillList.class, "Dragon");
assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(sk, dragon));
pc.incrementClassLevel(1, dragon);
assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
assertTrue(lscFacet.contains(id, dragonCSL, SkillCost.CROSS_CLASS, sk));
raceFacet.remove(id);
assertFalse(lscFacet.contains(id, dragonCSL, SkillCost.CROSS_CLASS, sk));
}
use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.
the class ClassesToken method parseTokenWithSeparator.
@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Skill skill, String value) {
StringTokenizer pipeTok = new StringTokenizer(value, Constants.PIPE);
boolean added = false;
List<CDOMReference<ClassSkillList>> allow = new ArrayList<>();
while (pipeTok.hasMoreTokens()) {
String className = pipeTok.nextToken();
if (Constants.LST_ALL.equals(className)) {
if (added) {
return new ParseResult.Fail("Non-sensical Skill " + getTokenName() + ": Contains ALL after a specific reference: " + value, context);
}
break;
}
if (className.startsWith("!")) {
return new ParseResult.Fail("Non-sensical Skill " + getTokenName() + ": Contains ! without (or before) ALL: " + value, context);
}
allow.add(context.getReferenceContext().getCDOMReference(SKILLLIST_CLASS, className));
added = true;
}
if (pipeTok.hasMoreTokens()) {
// allow is not used (empty or an error)
FilteredReference<ClassSkillList> filtered = new FilteredReference<>(SKILLLIST_CLASS, context.getReferenceContext().getCDOMAllReference(SKILLLIST_CLASS));
while (pipeTok.hasMoreTokens()) {
String className = pipeTok.nextToken();
if (className.startsWith("!")) {
String clString = className.substring(1);
if (Constants.LST_ALL.equals(clString) || Constants.LST_ANY.equals(clString)) {
return new ParseResult.Fail("Invalid " + getTokenName() + " cannot use !ALL", context);
}
CDOMSingleRef<ClassSkillList> ref = context.getReferenceContext().getCDOMReference(SKILLLIST_CLASS, clString);
filtered.addProhibitedItem(ref);
} else {
return new ParseResult.Fail("Non-sensical Skill " + getTokenName() + ": Contains ALL and a specific reference: " + value, context);
}
}
context.getListContext().addToMasterList(getTokenName(), skill, filtered, skill);
} else if (allow.isEmpty()) {
// unqualified ALL
context.getListContext().addToMasterList(getTokenName(), skill, context.getReferenceContext().getCDOMAllReference(SKILLLIST_CLASS), skill);
} else {
// use allow
for (CDOMReference<ClassSkillList> ref : allow) {
context.getListContext().addToMasterList(getTokenName(), skill, ref, skill);
}
}
return ParseResult.SUCCESS;
}
use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.
the class CskillToken method process.
@Override
public boolean process(LoadContext context, PCClass obj) {
List<CDOMReference<Skill>> list = obj.getListFor(ListKey.CLASS_SKILL);
if (list != null) {
ClassSkillList csl = obj.get(ObjectKey.CLASS_SKILLLIST);
CDOMDirectSingleRef<ClassSkillList> listref = new CDOMDirectSingleRef<>(csl);
for (CDOMReference<Skill> ref : list) {
for (Skill sk : ref.getContainedObjects()) {
context.getListContext().addToMasterList(getTokenName(), obj, listref, sk);
context.commit();
}
}
}
return true;
}
use of pcgen.cdom.list.ClassSkillList in project pcgen by PCGen.
the class ListToSkillCostFacet method dataAdded.
@Override
public void dataAdded(SubScopeFacetChangeEvent<ClassSkillList, SkillCost, Skill> dfce) {
CharID id = dfce.getCharID();
ClassSkillList skilllist = dfce.getScope1();
SkillCost cost = dfce.getScope2();
Skill sk = dfce.getCDOMObject();
for (PCClass cl : skillListFacet.getScopes(id)) {
if (skillListFacet.contains(id, cl, skilllist)) {
add(id, cl, cost, sk, cl);
}
}
}
Aggregations