use of pcgen.cdom.content.CNAbility 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.cdom.content.CNAbility in project pcgen by PCGen.
the class AddAbilityVirtualTest method testMult.
@Test
public void testMult() throws PersistenceLayerException {
TokenRegistration.register(new NoChoiceToken());
TokenRegistration.register(new StackToken());
Domain source = create(Domain.class, "Source");
PCClass pcc = create(PCClass.class, "Class");
Ability a = createGrantedObject();
context.unconditionallyProcess(a, "MULT", "YES");
context.unconditionallyProcess(a, "STACK", "YES");
context.unconditionallyProcess(a, "CHOOSE", "NOCHOICE");
runToken(source);
processToken(source);
assocCheck = new AssocCheck() {
public boolean check(CNAbility g) {
if (pc.getDetailedAssociationCount(g) == 2) {
return true;
} else {
System.err.println("Incorrect Association Count");
return false;
}
}
};
assertEquals(0, getCount());
ClassSource classSource = new ClassSource(pcc);
domainFacet.add(id, source, classSource);
assertTrue(containsExpected(a));
assertEquals(2, getCount());
domainFacet.remove(id, source);
assertEquals(0, getCount());
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AddAbilityNormalTest method testMult.
//TODO this appears to be a bug - is only applied once?
@Test
public void testMult() throws PersistenceLayerException {
TokenRegistration.register(new NoChoiceToken());
TokenRegistration.register(new StackToken());
Domain source = create(Domain.class, "Source");
PCClass pcc = create(PCClass.class, "Class");
Ability a = createGrantedObject();
context.unconditionallyProcess(a, "MULT", "YES");
context.unconditionallyProcess(a, "STACK", "YES");
context.unconditionallyProcess(a, "CHOOSE", "NOCHOICE");
runToken(source);
processToken(source);
assocCheck = new AssocCheck() {
public boolean check(CNAbility g) {
if (pc.getDetailedAssociationCount(g) == 2) {
return true;
} else {
System.err.println("Incorrect Association Count");
return false;
}
}
};
assertEquals(0, getCount());
ClassSource classSource = new ClassSource(pcc);
domainFacet.add(id, source, classSource);
assertTrue(containsExpected(a));
assertEquals(2, getCount());
domainFacet.remove(id, source);
assertEquals(0, getCount());
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AddAbilityNormalTest method containsExpected.
@Override
protected boolean containsExpected(Ability granted) {
Collection<CNAbility> abilities = getTargetFacet().getPoolAbilities(id, AbilityCategory.FEAT, Nature.NORMAL);
if (abilities.isEmpty()) {
System.err.println("No Abilities");
return false;
}
for (CNAbility a : abilities) {
boolean abilityExpected = a.getAbility().equals(context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Granted"));
if (abilityExpected) {
boolean c = assocCheck.check(a);
if (!c) {
System.err.println("Incorrect Associations");
}
return c;
}
}
System.err.println("Did not find Ability: Granted");
return false;
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AddAbilityVirtualTest method containsExpected.
@Override
protected boolean containsExpected(Ability granted) {
Collection<CNAbility> abilities = getTargetFacet().getPoolAbilities(id, AbilityCategory.FEAT, Nature.VIRTUAL);
for (CNAbility a : abilities) {
boolean abilityExpected = a.getAbility().equals(context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Granted"));
if (abilityExpected) {
boolean c = assocCheck.check(a);
if (!c) {
System.err.println("Incorrect Associations");
}
return c;
}
}
System.err.println("Did not find Ability");
return false;
}
Aggregations