use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class PreDomainTest method testAny.
/**
* Test for any domain.
*
* @throws Exception
*/
public void testAny() throws Exception {
final PlayerCharacter character = getCharacter();
PCClass cl = new PCClass();
character.setDefaultDomainSource(new ClassSource(cl, 1));
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDOMAIN:1,ANY");
assertFalse("Character has no domains", PrereqHandler.passes(prereq, character, null));
character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
assertTrue("Character has one domain", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDOMAIN:2,ANY");
assertFalse("Character has only one domain", PrereqHandler.passes(prereq, character, null));
character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Animal"));
assertTrue("Character has two domains", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class DomainCSkillTest method testList.
@Test
public void testList() throws PersistenceLayerException {
Domain source = create(Domain.class, "Source");
ParseResult result = token.parseToken(context, source, "LIST");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
result = CHOOSE_SKILL_TOKEN.parseToken(context, source, "MySkill");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
finishLoad();
assertFalse(lascFacet.contains(id, dragon, SkillCost.CLASS, sk));
assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
domainInputFacet.add(id, source, new ClassSource(dragon, 0));
assertTrue(lascFacet.contains(id, dragon, SkillCost.CLASS, sk));
pc.addClass(dragon);
pc.setDirty(true);
assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(sk, dragon));
domainInputFacet.remove(id, source);
assertFalse(lascFacet.contains(id, dragon, SkillCost.CLASS, sk));
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class DomainCcSkillTest method testList.
@Test
public void testList() throws PersistenceLayerException {
Domain source = create(Domain.class, "Source");
ParseResult result = token.parseToken(context, source, "LIST");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
result = CHOOSE_SKILL_TOKEN.parseToken(context, source, "MySkill");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
new ExclusiveToken().parseToken(context, sk, "Yes");
finishLoad();
assertFalse(lascFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(sk, dragon));
domainInputFacet.add(id, source, new ClassSource(dragon, 0));
assertTrue(lascFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
pc.addClass(dragon);
pc.setDirty(true);
assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
domainInputFacet.remove(id, source);
assertFalse(lascFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class DomainCcSkillTest method testDirect.
@Test
public void testDirect() throws PersistenceLayerException {
Domain source = create(Domain.class, "Source");
ParseResult result = token.parseToken(context, source, "MySkill");
if (result != ParseResult.SUCCESS) {
result.printMessages();
fail("Test Setup Failed");
}
new ExclusiveToken().parseToken(context, sk, "Yes");
finishLoad();
assertEquals(SkillCost.EXCLUSIVE, pc.getSkillCostForClass(sk, dragon));
domainInputFacet.add(id, source, new ClassSource(dragon, 0));
assertTrue(lscFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
pc.addClass(dragon);
pc.setDirty(true);
assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
domainInputFacet.remove(id, source);
assertFalse(lscFacet.contains(id, dragon, SkillCost.CROSS_CLASS, sk));
}
use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.
the class AbstractContentTokenTest method testFromDomain.
@Test
public void testFromDomain() throws PersistenceLayerException {
Domain source = create(Domain.class, "Source");
PCClass pcc = create(PCClass.class, "Class");
processToken(source);
assertEquals(baseCount(), targetFacetCount());
ClassSource classSource = new ClassSource(pcc);
domainFacet.add(id, source, classSource);
assertTrue(containsExpected());
assertEquals(baseCount() + 1, targetFacetCount());
domainFacet.remove(id, source, classSource);
assertEquals(baseCount(), targetFacetCount());
}
Aggregations