use of pcgen.core.Ability in project pcgen by PCGen.
the class AbilityDepthTest method createAbility.
private Ability createAbility(String key) {
Ability a = context.getReferenceContext().constructCDOMObject(Ability.class, key);
context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, a);
return a;
}
use of pcgen.core.Ability 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.core.Ability 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.core.Ability 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;
}
use of pcgen.core.Ability in project pcgen by PCGen.
the class AbstractContentTokenTest method testFromAbility.
@Test
public void testFromAbility() throws PersistenceLayerException {
Ability source = create(Ability.class, "Source");
context.getReferenceContext().reassociateCategory(AbilityCategory.FEAT, source);
processToken(source);
assertEquals(baseCount(), targetFacetCount());
CNAbilitySelection cas = new CNAbilitySelection(CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.AUTOMATIC, source));
directAbilityFacet.add(id, cas, UserSelection.getInstance());
assertTrue(containsExpected());
assertEquals(baseCount() + 1, targetFacetCount());
directAbilityFacet.remove(id, cas, UserSelection.getInstance());
assertEquals(baseCount(), targetFacetCount());
}
Aggregations