Search in sources :

Example 91 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PreClassTest method testSpellcaster.

/**
	 * Test to ensure that a character with a spellcasting class can be found
	 * @throws Exception
	 */
public void testSpellcaster() throws Exception {
    LoadContext context = Globals.getContext();
    final PCClass pcClass = context.getReferenceContext().constructCDOMObject(PCClass.class, "MyClass");
    BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
    context.unconditionallyProcess(pcClass.getOriginalClassLevel(1), "CAST", "5,4");
    context.unconditionallyProcess(pcClass, "SPELLSTAT", "CHA");
    context.getReferenceContext().buildDerivedObjects();
    context.getReferenceContext().resolveReferences(null);
    context.loadCampaignFacets();
    final PlayerCharacter character = getCharacter();
    setPCStat(character, cha, 12);
    character.incrementClassLevel(1, pcClass);
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("class");
    prereq.setKey("Spellcaster");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.GTEQ);
    final PreClassTester test = new PreClassTester();
    final int passes = test.passes(prereq, character, null);
    assertEquals(1, passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreClassTester(plugin.pretokens.test.PreClassTester) LoadContext(pcgen.rules.context.LoadContext) PCClass(pcgen.core.PCClass)

Example 92 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PreClassTest method testNamedClassFail.

/**
	 * Test to ensure that a character without a named class cannot be found
	 * @throws Exception
	 */
public void testNamedClassFail() throws Exception {
    final PCClass pcClass = new PCClass();
    pcClass.setName("MyClass");
    BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
    final PlayerCharacter character = getCharacter();
    character.incrementClassLevel(1, pcClass);
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("class");
    prereq.setKey("Druid");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.GTEQ);
    final PreClassTester test = new PreClassTester();
    final int passes = test.passes(prereq, character, null);
    assertEquals(0, passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreClassTester(plugin.pretokens.test.PreClassTester) PCClass(pcgen.core.PCClass)

Example 93 with PCClass

use of pcgen.core.PCClass 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 94 with PCClass

use of pcgen.core.PCClass in project pcgen by PCGen.

the class PreClassTest method testCharWithMultipleClasses.

/**
	 * Test to ensure that a character will fail a test
	 * if it does not have the correct number of levels
	 * in the class.
	 * @throws Exception
	 */
public void testCharWithMultipleClasses() throws Exception {
    final PCClass pcClass = new PCClass();
    pcClass.setName("MyClass");
    BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
    final PCClass pcClass2 = new PCClass();
    pcClass2.setName("Other Class");
    final PlayerCharacter character = getCharacter();
    character.incrementClassLevel(1, pcClass);
    character.incrementClassLevel(2, pcClass2);
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("class");
    prereq.setKey("other class");
    prereq.setOperand("2");
    prereq.setOperator(PrerequisiteOperator.GTEQ);
    final PreClassTester test = new PreClassTester();
    final int passes = test.passes(prereq, character, null);
    assertEquals(1, passes);
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreClassTester(plugin.pretokens.test.PreClassTester) PCClass(pcgen.core.PCClass)

Example 95 with PCClass

use of pcgen.core.PCClass 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)

Aggregations

PCClass (pcgen.core.PCClass)359 Test (org.junit.Test)96 PlayerCharacter (pcgen.core.PlayerCharacter)61 Skill (pcgen.core.Skill)55 ArrayList (java.util.ArrayList)35 Domain (pcgen.core.Domain)30 LoadContext (pcgen.rules.context.LoadContext)28 PCClassLevel (pcgen.cdom.inst.PCClassLevel)26 CDOMObject (pcgen.cdom.base.CDOMObject)23 CharacterSpell (pcgen.core.character.CharacterSpell)20 Spell (pcgen.core.spell.Spell)20 StringTokenizer (java.util.StringTokenizer)19 CharID (pcgen.cdom.enumeration.CharID)19 ClassSource (pcgen.cdom.helper.ClassSource)19 PreClassTester (plugin.pretokens.test.PreClassTester)16 SkillCost (pcgen.cdom.enumeration.SkillCost)15 ParseResult (pcgen.rules.persistence.token.ParseResult)15 Ability (pcgen.core.Ability)14 Race (pcgen.core.Race)14 BonusObj (pcgen.core.bonus.BonusObj)14