Search in sources :

Example 1 with IndividualSetup

use of pcgen.base.solver.IndividualSetup in project pcgen by PCGen.

the class PlayerCharacter method doFormulaSetup.

private void doFormulaSetup(LoadContext context) {
    SplitFormulaSetup formulaSetup = formulaSetupFacet.get(id.getDatasetID());
    MonitorableVariableStore varStore = new MonitorableVariableStore();
    IndividualSetup mySetup = new IndividualSetup(formulaSetup, "Global", varStore);
    scopeFacet.set(id, mySetup.getInstanceFactory());
    variableStoreFacet.set(id, varStore);
    SolverFactory solverFactory = solverFactoryFacet.get(id.getDatasetID());
    solverManagerFacet.set(id, new DynamicSolverManager(mySetup.getFormulaManager(), context.getVariableContext().getManagerFactory(), solverFactory, varStore));
}
Also used : SplitFormulaSetup(pcgen.base.solver.SplitFormulaSetup) DynamicSolverManager(pcgen.base.solver.DynamicSolverManager) IndividualSetup(pcgen.base.solver.IndividualSetup) SolverFactory(pcgen.base.solver.SolverFactory) MonitorableVariableStore(pcgen.cdom.formula.MonitorableVariableStore)

Example 2 with IndividualSetup

use of pcgen.base.solver.IndividualSetup in project pcgen by PCGen.

the class SetNumberModifierTest method testGetFormulaModifier.

@Test
public void testGetFormulaModifier() {
    SplitFormulaSetup setup = new SplitFormulaSetup();
    setup.loadBuiltIns();
    setup.getLegalScopeLibrary().registerScope(varScope);
    IndividualSetup iSetup = new IndividualSetup(setup, "Global", new SimpleVariableStore());
    SetModifierFactory factory = new SetModifierFactory();
    Modifier<Number> modifier = factory.getModifier(35, "6+5", new ManagerFactory() {
    }, iSetup.getFormulaManager(), varScope, numManager);
    assertEquals((35L << 32) + factory.getInherentPriority(), modifier.getPriority());
    assertSame(Number.class, modifier.getVariableFormat());
    EvaluationManager evalManager = EvalManagerUtilities.getInputEM(4.3);
    assertEquals(11, modifier.process(evalManager.getWith(EvaluationManager.FMANAGER, iSetup.getFormulaManager())));
}
Also used : SplitFormulaSetup(pcgen.base.solver.SplitFormulaSetup) ManagerFactory(pcgen.base.formula.base.ManagerFactory) SimpleVariableStore(pcgen.base.formula.inst.SimpleVariableStore) IndividualSetup(pcgen.base.solver.IndividualSetup) EvaluationManager(pcgen.base.formula.base.EvaluationManager) Test(org.junit.Test)

Example 3 with IndividualSetup

use of pcgen.base.solver.IndividualSetup in project pcgen by PCGen.

the class AbstractFormulaTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    setup = new SplitFormulaSetup();
    LegalScopeUtilities.loadLegalScopeLibrary(setup.getLegalScopeLibrary());
    localSetup = new IndividualSetup(setup, "Global", new MonitorableVariableStore());
    setup.getSolverFactory().addSolverFormat(Number.class, new Modifier() {

        @Override
        public Object process(EvaluationManager manager) {
            return 0;
        }

        @Override
        public void getDependencies(DependencyManager fdm) {
        }

        @Override
        public long getPriority() {
            return 0;
        }

        @Override
        public Class getVariableFormat() {
            return Number.class;
        }

        @Override
        public String getIdentification() {
            return "SET";
        }

        @Override
        public String getInstructions() {
            return "0";
        }
    });
    setup.getSolverFactory().addSolverFormat(String.class, new Modifier() {

        @Override
        public Object process(EvaluationManager manager) {
            return "";
        }

        @Override
        public void getDependencies(DependencyManager fdm) {
        }

        @Override
        public long getPriority() {
            return 0;
        }

        @Override
        public Class getVariableFormat() {
            return String.class;
        }

        @Override
        public String getIdentification() {
            return "SET";
        }

        @Override
        public String getInstructions() {
            return "";
        }
    });
}
Also used : SplitFormulaSetup(pcgen.base.solver.SplitFormulaSetup) IndividualSetup(pcgen.base.solver.IndividualSetup) DependencyManager(pcgen.base.formula.base.DependencyManager) EvaluationManager(pcgen.base.formula.base.EvaluationManager) MonitorableVariableStore(pcgen.cdom.formula.MonitorableVariableStore) Modifier(pcgen.base.solver.Modifier)

Example 4 with IndividualSetup

use of pcgen.base.solver.IndividualSetup 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)

Aggregations

IndividualSetup (pcgen.base.solver.IndividualSetup)4 SplitFormulaSetup (pcgen.base.solver.SplitFormulaSetup)3 MonitorableVariableStore (pcgen.cdom.formula.MonitorableVariableStore)3 EvaluationManager (pcgen.base.formula.base.EvaluationManager)2 Test (org.junit.Test)1 DependencyManager (pcgen.base.formula.base.DependencyManager)1 ManagerFactory (pcgen.base.formula.base.ManagerFactory)1 SimpleVariableStore (pcgen.base.formula.inst.SimpleVariableStore)1 DynamicSolverManager (pcgen.base.solver.DynamicSolverManager)1 Modifier (pcgen.base.solver.Modifier)1 SolverFactory (pcgen.base.solver.SolverFactory)1 ConsolidatedListCommitStrategy (pcgen.rules.context.ConsolidatedListCommitStrategy)1 RuntimeLoadContext (pcgen.rules.context.RuntimeLoadContext)1 RuntimeReferenceContext (pcgen.rules.context.RuntimeReferenceContext)1