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));
}
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())));
}
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 "";
}
});
}
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);
}
Aggregations