Search in sources :

Example 11 with ConsolidatedListCommitStrategy

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

the class DropIntoContextFunctionTest method testBasic.

@Test
public void testBasic() {
    VariableLibrary vl = getVariableLibrary();
    LegalScope equipScope = getScopeLibrary().getScope("EQUIPMENT");
    vl.assertLegalVariableID("LocalVar", equipScope, numberManager);
    String formula = "dropIntoContext(\"EQUIPMENT\",\"EquipKey\",LocalVar)";
    SimpleNode node = TestUtilities.doParse(formula);
    SemanticsVisitor semanticsVisitor = new SemanticsVisitor();
    FormulaSemantics semantics = generateFormulaSemantics(getFormulaManager(), getGlobalScope(), null);
    semanticsVisitor.visit(node, semantics);
    if (!semantics.isValid()) {
        TestCase.fail("Expected Valid Formula: " + formula + " but was told: " + semantics.getReport());
    }
    isStatic(formula, node, false);
    Equipment equip = new Equipment();
    equip.setName("EquipKey");
    ScopeInstance scopeInst = getInstanceFactory().get("EQUIPMENT", equip);
    VariableID varID = vl.getVariableID(scopeInst, "LocalVar");
    getVariableStore().put(varID, 2);
    LoadContext context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.getReferenceContext().importObject(equip);
    evaluatesTo(formula, node, 2, context);
    Object rv = new ReconstructionVisitor().visit(node, new StringBuilder());
    assertEquals(rv.toString(), formula);
}
Also used : ScopeInstance(pcgen.base.formula.base.ScopeInstance) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) FormulaSemantics(pcgen.base.formula.base.FormulaSemantics) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) VariableLibrary(pcgen.base.formula.base.VariableLibrary) SimpleNode(pcgen.base.formula.parse.SimpleNode) SemanticsVisitor(pcgen.base.formula.visitor.SemanticsVisitor) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) Equipment(pcgen.core.Equipment) ReconstructionVisitor(pcgen.base.formula.visitor.ReconstructionVisitor) LegalScope(pcgen.base.formula.base.LegalScope) LoadContext(pcgen.rules.context.LoadContext) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) VariableID(pcgen.base.formula.base.VariableID) Test(org.junit.Test)

Example 12 with ConsolidatedListCommitStrategy

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

the class AbstractPCClassLevelTokenTestCase 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());
    primaryProf = primaryContext.getReferenceContext().constructCDOMObject(PCClass.class, "TestObj");
    secondaryProf = secondaryContext.getReferenceContext().constructCDOMObject(PCClass.class, "TestObj");
    primaryProf1 = primaryProf.getOriginalClassLevel(1);
    primaryProf2 = primaryProf.getOriginalClassLevel(2);
    primaryProf3 = primaryProf.getOriginalClassLevel(3);
    secondaryProf1 = secondaryProf.getOriginalClassLevel(1);
    secondaryProf2 = secondaryProf.getOriginalClassLevel(2);
    secondaryProf3 = secondaryProf.getOriginalClassLevel(3);
}
Also used : ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) PCClass(pcgen.core.PCClass) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext) Before(org.junit.Before)

Example 13 with ConsolidatedListCommitStrategy

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

the class SelectableTokenIntegrationTest method resetContext.

private void resetContext() {
    URI testURI = testCampaign.getURI();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.setSourceURI(testURI);
    context.setExtractURI(testURI);
    cd = new FactDefinition();
    cd.setDisplayName(PROP_1);
    cd.setFormatManager(STRING_MGR);
    cd.setName(PROP_1);
    cd.setFactName(PROP_1);
    cd.setUsableLocation(Domain.class);
    cd.setVisibility(Visibility.DEFAULT);
}
Also used : FactDefinition(pcgen.cdom.content.fact.FactDefinition) ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) URI(java.net.URI) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 14 with ConsolidatedListCommitStrategy

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

the class AbilityListTokenTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    context.getReferenceContext().importObject(AbilityCategory.FEAT);
}
Also used : ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

Example 15 with ConsolidatedListCommitStrategy

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

the class AddedBonusFacetTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
    addBonus(Combat.class);
}
Also used : ConsolidatedListCommitStrategy(pcgen.rules.context.ConsolidatedListCommitStrategy) RuntimeReferenceContext(pcgen.rules.context.RuntimeReferenceContext) RuntimeLoadContext(pcgen.rules.context.RuntimeLoadContext)

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