Search in sources :

Example 21 with ClassSource

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));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain) ClassSource(pcgen.cdom.helper.ClassSource)

Example 22 with ClassSource

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));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Domain(pcgen.core.Domain) ClassSource(pcgen.cdom.helper.ClassSource) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 23 with ClassSource

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));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Domain(pcgen.core.Domain) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) ClassSource(pcgen.cdom.helper.ClassSource) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 24 with ClassSource

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));
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) Domain(pcgen.core.Domain) ExclusiveToken(plugin.lsttokens.skill.ExclusiveToken) ClassSource(pcgen.cdom.helper.ClassSource) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 25 with ClassSource

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());
}
Also used : Domain(pcgen.core.Domain) PCClass(pcgen.core.PCClass) ClassSource(pcgen.cdom.helper.ClassSource) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Aggregations

ClassSource (pcgen.cdom.helper.ClassSource)31 PCClass (pcgen.core.PCClass)19 Domain (pcgen.core.Domain)18 Test (org.junit.Test)9 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)6 ParseResult (pcgen.rules.persistence.token.ParseResult)5 PlayerCharacter (pcgen.core.PlayerCharacter)4 CNAbility (pcgen.cdom.content.CNAbility)3 Ability (pcgen.core.Ability)3 CharacterSpell (pcgen.core.character.CharacterSpell)3 Spell (pcgen.core.spell.Spell)3 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)3 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)2 CDOMReference (pcgen.cdom.base.CDOMReference)2 Type (pcgen.cdom.enumeration.Type)2 SpellSchool (pcgen.cdom.identifier.SpellSchool)2 DomainSpellList (pcgen.cdom.list.DomainSpellList)2 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)2 MessageType (pcgen.core.utils.MessageType)2 AttackType (pcgen.util.enumeration.AttackType)2