Search in sources :

Example 11 with ClassSource

use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.

the class DomainCSkillTest 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");
    }
    finishLoad();
    assertEquals(SkillCost.CROSS_CLASS, pc.getSkillCostForClass(sk, dragon));
    domainInputFacet.add(id, source, new ClassSource(dragon, 0));
    assertTrue(lscFacet.contains(id, dragon, SkillCost.CLASS, sk));
    pc.addClass(dragon);
    pc.setDirty(true);
    assertEquals(SkillCost.CLASS, pc.getSkillCostForClass(sk, dragon));
    domainInputFacet.remove(id, source);
    assertFalse(lscFacet.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 12 with ClassSource

use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.

the class PreDomainTest method testMultiple.

/**
	 * Test with multiple options
	 * @throws Exception
	 */
public void testMultiple() 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,Good,Law");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    character.setAlignment(ng);
    character.setDeity(deity);
    assertFalse("Character's deity has Good domain", PrereqHandler.passes(prereq, character, null));
    character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
    assertTrue("Character has Good domain", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDOMAIN:2,Good,Law");
    assertFalse("Character doesn't have Law domain", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDOMAIN:2,Good,Animal");
    character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Animal"));
    assertTrue("Character's deity has Good and animal 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 13 with ClassSource

use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.

the class PreDomainTest method testDeity.

/**
	 * Test to make sure it is not looking at deity domains
	 * @throws Exception
	 */
public void testDeity() 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,Good");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    character.setAlignment(ng);
    character.setDeity(deity);
    assertFalse("Character's deity has Good domain", PrereqHandler.passes(prereq, character, null));
    character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
    assertTrue("Character has Good domain", 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 14 with ClassSource

use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.

the class DomainFacetTest method developSource.

@Override
protected ClassSource developSource() {
    PCClass cl = new PCClass();
    cl.setName("Class" + n++);
    return new ClassSource(cl);
}
Also used : PCClass(pcgen.core.PCClass) ClassSource(pcgen.cdom.helper.ClassSource)

Example 15 with ClassSource

use of pcgen.cdom.helper.ClassSource in project pcgen by PCGen.

the class DomainTargetSaveRestoreTest method applyObject.

@Override
protected void applyObject(Domain obj) {
    PCClass cl = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, "MyClass");
    pc.addClass(cl);
    pc.incrementClassLevel(1, cl);
    pc.setHP(pc.getActiveClassLevel(cl, 0), 4);
    pc.addDomain(obj, new ClassSource(cl, 1));
}
Also used : PCClass(pcgen.core.PCClass) ClassSource(pcgen.cdom.helper.ClassSource)

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