use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.
the class BonusLst method process.
@Override
public boolean process(LoadContext context, CDOMObject obj) {
List<BonusObj> bonusList = obj.getListFor(ListKey.BONUS);
boolean returnValue = true;
if (bonusList != null) {
for (BonusObj bonus : bonusList) {
String bonusName = bonus.getBonusName();
if ("ABILITYPOOL".equalsIgnoreCase(bonusName)) {
for (Object o : bonus.getBonusInfoList()) {
if (context.getReferenceContext().silentlyGetConstructedCDOMObject(ABILITY_CATEGORY_CLASS, o.toString()) == null) {
LoadContext dummyCtx = new RuntimeLoadContext(context.getReferenceContext(), new ConsolidatedListCommitStrategy());
dummyCtx.setSourceURI(obj.getSourceURI());
Logging.errorPrint("BONUS: " + bonus + " in " + obj.getClass().getSimpleName() + ' ' + obj.getKeyName() + " contained an invalid AbilityCategory " + o.toString(), dummyCtx);
returnValue = false;
}
}
} else if ("UDAM".equals(bonusName)) {
for (Object o : bonus.getBonusInfoList()) {
String classKey = o.toString();
final PCClass aClass = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCCLASS_CLASS, classKey);
if (aClass == null) {
Logging.errorPrint("Could not find class '" + classKey + "' for UDAM token", context);
}
}
}
}
}
try {
obj.ownBonuses(obj);
} catch (CloneNotSupportedException e) {
Logging.errorPrint(e.getLocalizedMessage());
return false;
}
return returnValue;
}
use of pcgen.rules.context.RuntimeLoadContext 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());
}
use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.
the class AbstractGlobalTokenTestCase method setUp.
@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
if (!classSetUpFired) {
classSetUp();
}
TokenRegistration.register(getToken());
primaryContext = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
secondaryContext = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
primaryProf = primaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj");
secondaryProf = secondaryContext.getReferenceContext().constructCDOMObject(getCDOMClass(), "TestObj");
primaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
secondaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
}
use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.
the class AbstractKitTokenTestCase 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());
URI testURI = testCampaign.getURI();
primaryContext.setSourceURI(testURI);
primaryContext.setExtractURI(testURI);
secondaryContext.setSourceURI(testURI);
secondaryContext.setExtractURI(testURI);
primaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
secondaryContext.getReferenceContext().importObject(AbilityCategory.FEAT);
primaryProf = getSubInstance();
secondaryProf = getSubInstance();
expectedPrimaryMessageCount = 0;
}
use of pcgen.rules.context.RuntimeLoadContext in project pcgen by PCGen.
the class TableLoaderTest method setUp.
@Before
public void setUp() throws Exception {
uri = new URI("file:/Test%20Case");
context = new RuntimeLoadContext(new RuntimeReferenceContext(), new ConsolidatedListCommitStrategy());
loader = new TableLoader();
}
Aggregations