use of plugin.pretokens.test.PreClassTester in project pcgen by PCGen.
the class PreClassTest method testFromParserAny.
/**
* 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 testFromParserAny() throws Exception {
LoadContext context = Globals.getContext();
final PCClass pcClass = new PCClass();
pcClass.setName("MyClass");
context.unconditionallyProcess(pcClass, "SPELLSTAT", "CHA");
BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
context.unconditionallyProcess(pcClass.getOriginalClassLevel(1), "CAST", "5,4");
final PCClass pcClass2 = new PCClass();
pcClass2.setName("Other Class");
context.unconditionallyProcess(pcClass2, "SPELLSTAT", "INT");
BuildUtilities.setFact(pcClass2, "SpellType", "Arcane");
context.unconditionallyProcess(pcClass2.getOriginalClassLevel(1), "CAST", "5,4");
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(1, pcClass);
character.incrementClassLevel(2, pcClass2);
final PreParserFactory factory = PreParserFactory.getInstance();
final Prerequisite prereq = factory.parse("PRECLASS:1,ANY=3");
final PreClassTester test = new PreClassTester();
int passes = test.passes(prereq, character, null);
// Doens't pass - levels not summed...
assertEquals(0, passes);
character.incrementClassLevel(1, pcClass2);
passes = test.passes(prereq, character, null);
assertEquals(1, passes);
}
use of plugin.pretokens.test.PreClassTester in project pcgen by PCGen.
the class PreClassTest method testTooFewLevels.
/**
* 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 testTooFewLevels() 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("myclass");
prereq.setOperand("3");
prereq.setOperator(PrerequisiteOperator.GTEQ);
final PreClassTester test = new PreClassTester();
final int passes = test.passes(prereq, character, null);
assertEquals(0, passes);
}
use of plugin.pretokens.test.PreClassTester in project pcgen by PCGen.
the class PreClassTest method testAnyLevelsOneClass.
/**
* 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 testAnyLevelsOneClass() 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("Any");
prereq.setOperand("3");
prereq.setOperator(PrerequisiteOperator.GTEQ);
final PreClassTester test = new PreClassTester();
assertEquals(0, test.passes(prereq, character, null));
character.incrementClassLevel(2, pcClass);
assertEquals(1, test.passes(prereq, character, null));
}
use of plugin.pretokens.test.PreClassTester in project pcgen by PCGen.
the class PreClassTest method testNoLevelsPass.
/**
* Test to ensure that a character without a named class cannot be found
* @throws Exception
*/
public void testNoLevelsPass() 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("Druid");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.LT);
final PreClassTester test = new PreClassTester();
final int passes = test.passes(prereq, character, null);
assertEquals(1, passes);
}
use of plugin.pretokens.test.PreClassTester in project pcgen by PCGen.
the class PreClassTest method testNamedClass.
/**
* Test to ensure that a character with a named class can be found
* @throws Exception
*/
public void testNamedClass() throws Exception {
final PCClass pcClass = new PCClass();
pcClass.setName("MyClass");
BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(3, pcClass);
final Prerequisite prereq = new Prerequisite();
prereq.setKind("class");
prereq.setKey("myclass");
prereq.setOperand("1");
prereq.setOperator(PrerequisiteOperator.GTEQ);
final PreClassTester test = new PreClassTester();
final int passes = test.passes(prereq, character, null);
assertEquals(1, passes);
}
Aggregations