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);
}
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);
}
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));
}
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);
}
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));
}
Aggregations