Search in sources :

Example 16 with PreClassTester

use of plugin.pretokens.test.PreClassTester in project pcgen by PCGen.

the class PreClassTest method testSpellcasterTypePass.

/**
	 * Test to ensure that a character with a spellcasting class
	 * will pass a prerequisute that requires a level of that
	 * classes spell type.
	 * @throws Exception
	 */
public void testSpellcasterTypePass() 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().resolveReferences(null);
    context.getReferenceContext().buildDerivedObjects();
    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.ARCANE");
    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)

Aggregations

PCClass (pcgen.core.PCClass)16 PlayerCharacter (pcgen.core.PlayerCharacter)16 PreClassTester (plugin.pretokens.test.PreClassTester)16 LoadContext (pcgen.rules.context.LoadContext)6 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)2