Search in sources :

Example 16 with RuntimeLoadContext

use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.

the class BonusLst method process.

@Override
public boolean process(LoadContext context, CDOMObject obj) {
    List<BonusObj> bonusList = obj.getListFor(ListKey.BONUS);
    boolean returnValue = true;
    if (bonusList != null) {
        for (BonusObj bonus : bonusList) {
            String bonusName = bonus.getBonusName();
            if ("ABILITYPOOL".equalsIgnoreCase(bonusName)) {
                for (Object o : bonus.getBonusInfoList()) {
                    if (context.getReferenceContext().silentlyGetConstructedCDOMObject(ABILITY_CATEGORY_CLASS, o.toString()) == null) {
                        LoadContext dummyCtx = new RuntimeLoadContext(context.getReferenceContext(), new ConsolidatedListCommitStrategy());
                        dummyCtx.setSourceURI(obj.getSourceURI());
                        Logging.errorPrint("BONUS: " + bonus + " in " + obj.getClass().getSimpleName() + ' ' + obj.getKeyName() + " contained an invalid AbilityCategory " + o.toString(), dummyCtx);
                        returnValue = false;
                    }
                }
            } else if ("UDAM".equals(bonusName)) {
                for (Object o : bonus.getBonusInfoList()) {
                    String classKey = o.toString();
                    final PCClass aClass = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCCLASS_CLASS, classKey);
                    if (aClass == null) {
                        Logging.errorPrint("Could not find class '" + classKey + "' for UDAM token", context);
                    }
                }
            }
        }
    }
    try {
        obj.ownBonuses(obj);
    } catch (CloneNotSupportedException e) {
        Logging.errorPrint(e.getLocalizedMessage());
        return false;
    }
    return returnValue;
}
Also used : BonusObj(pcgen.core.bonus.BonusObj) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) LoadContext(pcgen.rules.context.LoadContext) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) CDOMObject(pcgen.cdom.base.CDOMObject) PCClass(pcgen.core.PCClass) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 17 with RuntimeLoadContext

use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.

the class AbstractFormulaTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    setup = context.getVariableContext().getFormulaSetup();
    setup.getSolverFactory().addSolverFormat(Number.class, getDMod(0));
    setup.getSolverFactory().addSolverFormat(String.class, getDMod(""));
    localSetup = new IndividualSetup(setup, "Global", new MonitorableVariableStore());
}
Also used : IndividualSetup(pcgen.base.solver.IndividualSetup) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) MonitorableVariableStore(pcgen.cdom.formula.MonitorableVariableStore) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 18 with RuntimeLoadContext

use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.

the class AbstractGlobalTokenTestCase method setUp.

@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
    if (!classSetUpFired) {
        classSetUp();
    }
    TokenRegistration.register(getToken());
    primaryContext = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    secondaryContext = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    primaryProf = primaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj");
    secondaryProf = secondaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj");
    primaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
    secondaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
}
Also used : ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) Before(org.junit.Before)

Example 19 with RuntimeLoadContext

use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.

the class AbstractKitTokenTestCase method setUp.

@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
    if (!classSetUpFired) {
        classSetUp();
    }
    // Yea, this causes warnings...
    TokenRegistration.register(getToken());
    primaryContext = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    secondaryContext = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    URI testURI = testCampaign.getURI();
    primaryContext.setSourceURI(testURI);
    primaryContext.setExtractURI(testURI);
    secondaryContext.setSourceURI(testURI);
    secondaryContext.setExtractURI(testURI);
    primaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
    secondaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
    primaryProf = getSubInstance();
    secondaryProf = getSubInstance();
    expectedPrimaryMessageCount = 0;
}
Also used : ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) Before(org.junit.Before)

Example 20 with RuntimeLoadContext

use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.

the class TableLoaderTest method setUp.

@Before
public void setUp() throws Exception {
    uri = new URI("file:/Test%20Case");
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    loader = new TableLoader();
}
Also used : ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) Before(org.junit.Before)

Aggregations

ConsolidatedListCommitStrategy (pcgen.rules.context.ConsolidatedListCommitStrategy)25 RuntimeLoadContext (pcgen.rules.context.RuntimeLoadContext)25 RuntimeReferenceContext (pcgen.rules.context.RuntimeReferenceContext)23 URI (java.net.URI)14 FactDefinition (pcgen.cdom.content.fact.FactDefinition)8 Before (org.junit.Before)4 LoadContext (pcgen.rules.context.LoadContext)3 Test (org.junit.Test)2 FormulaSemantics (pcgen.base.formula.base.FormulaSemantics)2 LegalScope (pcgen.base.formula.base.LegalScope)2 ScopeInstance (pcgen.base.formula.base.ScopeInstance)2 VariableID (pcgen.base.formula.base.VariableID)2 VariableLibrary (pcgen.base.formula.base.VariableLibrary)2 SimpleNode (pcgen.base.formula.parse.SimpleNode)2 ReconstructionVisitor (pcgen.base.formula.visitor.ReconstructionVisitor)2 SemanticsVisitor (pcgen.base.formula.visitor.SemanticsVisitor)2 CDOMObject (pcgen.cdom.base.CDOMObject)2 UserFunction (pcgen.cdom.content.UserFunction)2 Equipment (pcgen.core.Equipment)2 PCClass (pcgen.core.PCClass)2