Search in sources :

Example 1 with LoadValidator

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);
    }
}
Also used : Equipment(pcgen.core.Equipment) AbstractReferenceContext(pcgen.rules.context.AbstractReferenceContext) LoadValidator(pcgen.rules.context.LoadValidator)

Example 2 with LoadValidator

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);
}
Also used : Ability(pcgen.core.Ability) ArrayList(java.util.ArrayList) LoadValidator(pcgen.rules.context.LoadValidator) CDOMSingleRef(pcgen.cdom.reference.CDOMSingleRef) AbilityCategory(pcgen.core.AbilityCategory)

Aggregations

LoadValidator (pcgen.rules.context.LoadValidator)2 ArrayList (java.util.ArrayList)1 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)1 Ability (pcgen.core.Ability)1 AbilityCategory (pcgen.core.AbilityCategory)1 Equipment (pcgen.core.Equipment)1 AbstractReferenceContext (pcgen.rules.context.AbstractReferenceContext)1