use of pcgen.rules.context.LoadValidator in project pcgen by PCGen.
the class SourceFileLoader method finishLoad.
private void finishLoad(final List<Campaign> aSelectedCampaignsList, LoadContext context) {
createLangBonusObject(context);
AbstractReferenceContext refContext = context.getReferenceContext();
refContext.buildDeferredObjects();
refContext.buildDerivedObjects();
referenceAllCategories(context);
context.resolveDeferredTokens();
LoadValidator validator = new LoadValidator(aSelectedCampaignsList);
refContext.validate(validator);
refContext.resolveReferences(validator);
context.resolvePostValidationTokens();
context.resolvePostDeferredTokens();
ReferenceContextUtilities.validateAssociations(refContext, validator);
for (Equipment eq : refContext.getConstructedCDOMObjects(Equipment.class)) {
eq.setToCustomSize(null);
EqModAttachment.finishEquipment(eq);
}
}
use of pcgen.rules.context.LoadValidator in project pcgen by PCGen.
the class AbilityListTokenTest method testEntriesWithAssoc.
/**
* Test that entries with associated choices are parsed correctly
*/
public void testEntriesWithAssoc() {
AbilityCategory aCat = context.getReferenceContext().constructCDOMObject(AbilityCategory.class, "TestCat");
aCat.setAbilityCategory(CDOMDirectSingleRef.getRef(AbilityCategory.FEAT));
assertFalse("Test category should start with an empty list of keys", aCat.hasDirectReferences());
assertEquals("Test category should start with an empty list of keys", 0, aCat.getAbilityRefs().size());
AbilityListToken token = new AbilityListToken();
Ability pbs = buildFeat(context, "Point Blank Shot");
Ability sf = buildFeat(context, "Skill Focus");
token.parseToken(context, aCat, "Point Blank Shot|Skill Focus (Ride)|Skill Focus (Bluff)");
assertEquals("Test category should now have 3 keys", 3, aCat.getAbilityRefs().size());
assertContains(aCat, pbs, true);
//Because this tests LST format
assertContains(aCat, sf, false);
context.getReferenceContext().validate(new LoadValidator(new ArrayList<>()));
assertTrue(context.getReferenceContext().resolveReferences(null));
Collection<CDOMSingleRef<Ability>> refs = aCat.getAbilityRefs();
boolean found = false;
for (CDOMSingleRef<Ability> ref : refs) {
found |= ref.contains(pbs);
}
assertTrue("Expected Point Blank Shot Ability", found);
found = false;
for (CDOMSingleRef<Ability> ref : refs) {
found |= ref.contains(sf);
}
assertTrue("Expected Skill Focus Ability", found);
}
Aggregations