Search in sources :

Example 1 with SimpleFunctionLibrary

use of pcgen.base.formula.inst.SimpleFunctionLibrary in project pcgen by PCGen.

the class SetSolverManagerTest method setUp.

@Before
public void setUp() throws Exception {
    FunctionLibrary fl = new SimpleFunctionLibrary();
    fl.addFunction(new DropIntoContext());
    OperatorLibrary ol = new SimpleOperatorLibrary();
    vc = new TrackingVariableCache();
    vsLib = new LegalScopeLibrary();
    EquipmentScope equipScope = new EquipmentScope();
    equipScope.setParent(globalScope);
    vsLib.registerScope(equipScope);
    sl = new VariableLibrary(vsLib);
    arrayManager = new ArrayFormatManager<>(stringManager, ',');
    ManagerFactory managerFactory = new ManagerFactory() {
    };
    siFactory = new ScopeInstanceFactory(vsLib);
    fm = new SimpleFormulaManager(ol, sl, siFactory, vc, new SolverFactory());
    fm = fm.getWith(FormulaManager.FUNCTION, fl);
    SolverFactory solverFactory = new SolverFactory();
    ModifierFactory am1 = new plugin.modifier.set.SetModifierFactory<>();
    PCGenModifier emptyArrayMod = am1.getModifier(0, "", managerFactory, null, globalScope, arrayManager);
    solverFactory.addSolverFormat(arrayManager.getManagedClass(), emptyArrayMod);
    NEPCalculation calc = new ProcessCalculation<>(new Equipment(), new BasicSet(), equipmentManager);
    CalculationModifier em = new CalculationModifier<>(calc, 0);
    solverFactory.addSolverFormat(Equipment.class, em);
    manager = new DynamicSolverManager(fm, managerFactory, solverFactory, vc);
    ModifierFactory mfn = new plugin.modifier.number.SetModifierFactory();
    Modifier mod = mfn.getModifier(0, "0", managerFactory, null, globalScope, numberManager);
    solverFactory.addSolverFormat(numberManager.getManagedClass(), mod);
    ModifierFactory mfs = new plugin.modifier.string.SetModifierFactory();
    Modifier mods = mfs.getModifier(0, "", managerFactory, null, globalScope, stringManager);
    solverFactory.addSolverFormat(stringManager.getManagedClass(), mods);
}
Also used : CalculationModifier(pcgen.base.calculation.CalculationModifier) ProcessCalculation(pcgen.cdom.content.ProcessCalculation) FunctionLibrary(pcgen.base.formula.base.FunctionLibrary) SimpleFunctionLibrary(pcgen.base.formula.inst.SimpleFunctionLibrary) NEPCalculation(pcgen.base.calculation.NEPCalculation) DropIntoContext(plugin.function.DropIntoContext) SimpleFormulaManager(pcgen.base.formula.inst.SimpleFormulaManager) ModifierFactory(pcgen.rules.persistence.token.ModifierFactory) EquipmentScope(pcgen.cdom.formula.scope.EquipmentScope) TrackingVariableCache(pcgen.base.solver.testsupport.TrackingVariableCache) OperatorLibrary(pcgen.base.formula.base.OperatorLibrary) SimpleOperatorLibrary(pcgen.base.formula.inst.SimpleOperatorLibrary) LegalScopeLibrary(pcgen.base.formula.base.LegalScopeLibrary) CalculationModifier(pcgen.base.calculation.CalculationModifier) PCGenModifier(pcgen.base.calculation.PCGenModifier) SimpleOperatorLibrary(pcgen.base.formula.inst.SimpleOperatorLibrary) SimpleFunctionLibrary(pcgen.base.formula.inst.SimpleFunctionLibrary) VariableLibrary(pcgen.base.formula.base.VariableLibrary) ManagerFactory(pcgen.base.formula.base.ManagerFactory) Equipment(pcgen.core.Equipment) ScopeInstanceFactory(pcgen.base.formula.inst.ScopeInstanceFactory) PCGenModifier(pcgen.base.calculation.PCGenModifier) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 CalculationModifier (pcgen.base.calculation.CalculationModifier)1 NEPCalculation (pcgen.base.calculation.NEPCalculation)1 PCGenModifier (pcgen.base.calculation.PCGenModifier)1 FunctionLibrary (pcgen.base.formula.base.FunctionLibrary)1 LegalScopeLibrary (pcgen.base.formula.base.LegalScopeLibrary)1 ManagerFactory (pcgen.base.formula.base.ManagerFactory)1 OperatorLibrary (pcgen.base.formula.base.OperatorLibrary)1 VariableLibrary (pcgen.base.formula.base.VariableLibrary)1 ScopeInstanceFactory (pcgen.base.formula.inst.ScopeInstanceFactory)1 SimpleFormulaManager (pcgen.base.formula.inst.SimpleFormulaManager)1 SimpleFunctionLibrary (pcgen.base.formula.inst.SimpleFunctionLibrary)1 SimpleOperatorLibrary (pcgen.base.formula.inst.SimpleOperatorLibrary)1 TrackingVariableCache (pcgen.base.solver.testsupport.TrackingVariableCache)1 ProcessCalculation (pcgen.cdom.content.ProcessCalculation)1 EquipmentScope (pcgen.cdom.formula.scope.EquipmentScope)1 Equipment (pcgen.core.Equipment)1 ModifierFactory (pcgen.rules.persistence.token.ModifierFactory)1 DropIntoContext (plugin.function.DropIntoContext)1