Search in sources :

Example 1 with PreClassTester

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

the class PreClassTest method testSpellcasterTypeWrongCasePass.

/**
	 * Test to ensure that a spellcaster type check is case insensitive
	 * @throws Exception
	 */
public void testSpellcasterTypeWrongCasePass() 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();
    character.incrementClassLevel(1, pcClass);
    setPCStat(character, cha, 12);
    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)

Example 2 with PreClassTester

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

the class PreClassTest method testNamedClassServesAs.

/**
	 * Test to ensure that a character with a ServeAs class can be found
	 * @throws Exception
	 */
public void testNamedClassServesAs() throws Exception {
    final PCClass pcClass = new PCClass();
    pcClass.setName("MyClass");
    final PCClass warrior = new PCClass();
    warrior.setName("Warrior");
    final PCClass ranger = new PCClass();
    ranger.setName("Ranger");
    pcClass.addToListFor(ListKey.SERVES_AS_CLASS, CDOMDirectSingleRef.getRef(warrior));
    pcClass.addToListFor(ListKey.SERVES_AS_CLASS, CDOMDirectSingleRef.getRef(ranger));
    final PlayerCharacter character = getCharacter();
    character.incrementClassLevel(3, pcClass);
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("class");
    prereq.setKey("Warrior");
    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) PCClass(pcgen.core.PCClass)

Example 3 with PreClassTester

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

the class PreClassTest method testNoLevelsFail.

/**
	 * Test to ensure that a character without a named class cannot be found
	 * @throws Exception
	 */
public void testNoLevelsFail() throws Exception {
    final PCClass pcClass = new PCClass();
    pcClass.setName("Monk");
    final PlayerCharacter character = getCharacter();
    character.incrementClassLevel(1, pcClass);
    final Prerequisite prereq = new Prerequisite();
    prereq.setKind("class");
    prereq.setKey("Monk");
    prereq.setOperand("1");
    prereq.setOperator(PrerequisiteOperator.LT);
    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 4 with PreClassTester

use of plugin.pretokens.test.PreClassTester 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 5 with PreClassTester

use of plugin.pretokens.test.PreClassTester 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)

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