Search in sources :

Example 1 with SplitFormulaSetup

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

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

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

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

the class FormulaSetupFacet method initialize.

@Override
public synchronized void initialize(LoadContext context) {
    DataSetID dsID = context.getDataSetID();
    SplitFormulaSetup formulaSetup = context.getVariableContext().getFormulaSetup();
    set(dsID, formulaSetup);
}
Also used : SplitFormulaSetup(pcgen.base.solver.SplitFormulaSetup) DataSetID(pcgen.cdom.enumeration.DataSetID)

Aggregations

SplitFormulaSetup (pcgen.base.solver.SplitFormulaSetup)4 IndividualSetup (pcgen.base.solver.IndividualSetup)3 EvaluationManager (pcgen.base.formula.base.EvaluationManager)2 MonitorableVariableStore (pcgen.cdom.formula.MonitorableVariableStore)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 DataSetID (pcgen.cdom.enumeration.DataSetID)1