use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class TemplateTargetSaveRestoreTest method testTemplateFavoredClass.
@Test
public void testTemplateFavoredClass() {
PCClass monclass = create(PCClass.class, "MonClass");
new TypeLst().parseToken(context, monclass, "Monster");
PCTemplate monster = create(PCTemplate.class, "Monster");
create(PCClass.class, "MyClass");
new FavoredclassToken().parseToken(context, monster, "%LIST");
new ClassToken().parseToken(context, monster, "MonClass|MyClass");
finishLoad();
pc.addTemplate(monster);
runRoundRobin(getPreEqualityCleanup());
assertTrue(pc.getDisplay().getFavoredClasses().contains(monclass));
assertTrue(reloadedPC.getDisplay().getFavoredClasses().contains(monclass));
reloadedPC.removeTemplate(monster);
reloadedPC.setDirty(true);
assertFalse(reloadedPC.getDisplay().getFavoredClasses().contains(monclass));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class GeneralSaveRestoreTest method testTemplateFeat.
public void testTemplateFeat() {
//Represents CODE-2547
TokenRegistration.register(new plugin.lsttokens.deprecated.TemplateFeatToken());
TokenRegistration.register(new plugin.lsttokens.ability.StackToken());
TokenRegistration.register(new plugin.exporttokens.deprecated.TemplateToken());
Language lang = context.getReferenceContext().constructCDOMObject(Language.class, "English");
Ability a = context.getReferenceContext().constructCDOMObject(Ability.class, "Ab");
context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, a);
PCTemplate pct = context.getReferenceContext().constructCDOMObject(PCTemplate.class, "Templ");
try {
assertTrue(context.processToken(a, "MULT", "YES"));
assertTrue(context.processToken(a, "STACK", "YES"));
assertTrue(context.processToken(a, "CHOOSE", "LANG|English"));
assertTrue(context.processToken(a, "AUTO", "LANG|%LIST"));
assertTrue(context.processToken(pct, "FEAT", "Ab"));
} catch (PersistenceLayerException e) {
fail(e.getMessage());
}
finishLoad();
pc.addTemplate(pct);
assertTrue(pc.hasLanguage(lang));
runRoundRobin(null);
assertTrue(reloadedPC.hasLanguage(lang));
List<CNAbility> cnaList = pc.getMatchingCNAbilities(a);
assertEquals(1, cnaList.size());
List<String> assocs = pc.getAssociationList(cnaList.get(0));
assertEquals(1, assocs.size());
assertEquals("English", assocs.get(0));
cnaList = reloadedPC.getMatchingCNAbilities(a);
assertEquals(1, cnaList.size());
assocs = reloadedPC.getAssociationList(cnaList.get(0));
assertEquals(1, assocs.size());
assertEquals("English", assocs.get(0));
assertEquals("Ab(English)", ExportHandler.getTokenString(pc, "TEMPLATE.0.FEAT"));
assertEquals("Ab(English)", ExportHandler.getTokenString(reloadedPC, "TEMPLATE.0.FEAT"));
reloadedPC.removeTemplate(pct);
assertFalse(reloadedPC.hasLanguage(lang));
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class BasicSaveRestoreTest method testTemplate.
//TODO No way to remove a alignment once set :(
// @Test
// public void testAlignmentAddRemove()
// {
// finishLoad();
// runWriteRead();
// pc.setAlignment(le);
// pc.removeAlignment();
// testEquality();
// }
@Test
public void testTemplate() {
PCTemplate template = create(PCTemplate.class, "MyTemplate");
finishLoad();
pc.addTemplate(template);
runRoundRobin(null);
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class TemplateFavoredClassTest method testList.
@Test
public void testList() throws PersistenceLayerException {
PCTemplate source = create(PCTemplate.class, "Source");
ParseResult result = token.parseToken(context, source, "%LIST");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
result = CHOOSE_CLASS_TOKEN.parseToken(context, source, "Favorite");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
finishLoad();
assertEquals(baseCount(), targetFacetCount());
templateInputFacet.add(id, source);
assertTrue(containsExpected());
assertEquals(baseCount() + 1, targetFacetCount());
templateInputFacet.remove(id, source);
assertEquals(baseCount(), targetFacetCount());
}
use of pcgen.core.PCTemplate in project pcgen by PCGen.
the class GlobalSpellKnownTest method testConditional.
public void testConditional() {
Ability source = create(Ability.class, "Source");
context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, source);
ParseResult result = token.parseToken(context, source, "CLASS|Wizard=2|Fireball|PREVARLTEQ:3,MyCasterLevel");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
finishLoad();
assertEquals(baseCount(), targetFacetCount());
CNAbilitySelection cas = new CNAbilitySelection(CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.AUTOMATIC, source));
directAbilityFacet.add(id, cas, UserSelection.getInstance());
assertFalse(containsExpected());
PCTemplate varsource = create(PCTemplate.class, "VarSource");
varsource.put(VariableKey.getConstant("MyCasterLevel"), FormulaFactory.getFormulaFor(4.0));
templateInputFacet.directAdd(id, varsource, null);
pc.calcActiveBonuses();
assertTrue(containsExpected());
assertEquals(baseCount() + 1, targetFacetCount());
directAbilityFacet.remove(id, cas, UserSelection.getInstance());
pc.calcActiveBonuses();
assertEquals(baseCount(), targetFacetCount());
}
Aggregations