use of pcgen.core.PCClass in project pcgen by PCGen.
the class PreClassTest method testAnyLevelsTwoClasses.
public void testAnyLevelsTwoClasses() throws Exception {
final PCClass pcClass = new PCClass();
pcClass.setName("MyClass");
BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
final PCClass pcClass2 = new PCClass();
pcClass2.setName("MyClass2");
BuildUtilities.setFact(pcClass2, "SpellType", "Divine");
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("PRECLASS:2,ANY=1");
character.incrementClassLevel(1, pcClass);
assertEquals(false, PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, pcClass2);
assertEquals(true, PrereqHandler.passes(prereq, character, null));
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class PreClassTest method testCharWithMultipleSpellClasses.
/**
* 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 testCharWithMultipleSpellClasses() throws Exception {
LoadContext context = Globals.getContext();
final PCClass pcClass = context.getReferenceContext().constructCDOMObject(PCClass.class, "MyClass");
context.unconditionallyProcess(pcClass, "SPELLSTAT", "CHA");
BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
context.unconditionallyProcess(pcClass.getOriginalClassLevel(1), "CAST", "5,4");
final PCClass pcClass2 = context.getReferenceContext().constructCDOMObject(PCClass.class, "Other Class");
context.unconditionallyProcess(pcClass2, "SPELLSTAT", "INT");
BuildUtilities.setFact(pcClass2, "SpellType", "Arcane");
context.unconditionallyProcess(pcClass2.getOriginalClassLevel(1), "CAST", "5,4");
context.getReferenceContext().buildDerivedObjects();
context.getReferenceContext().resolveReferences(null);
context.loadCampaignFacets();
final PlayerCharacter character = getCharacter();
setPCStat(character, cha, 12);
setPCStat(character, intel, 12);
character.incrementClassLevel(1, pcClass);
character.incrementClassLevel(2, pcClass2);
final Prerequisite prereq = new Prerequisite();
prereq.setKind("class");
prereq.setKey("SPELLCASTER.ARCANE");
prereq.setOperand("3");
prereq.setTotalValues(true);
prereq.setOperator(PrerequisiteOperator.GTEQ);
final PreClassTester test = new PreClassTester();
final int passes = test.passes(prereq, character, null);
assertEquals(3, passes);
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class PreClassTest method testFromParserCharWithMultipleSpellClasses.
/**
* 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 testFromParserCharWithMultipleSpellClasses() throws Exception {
LoadContext context = Globals.getContext();
final PCClass pcClass = context.getReferenceContext().constructCDOMObject(PCClass.class, "MyClass");
context.unconditionallyProcess(pcClass, "SPELLSTAT", "CHA");
BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
context.unconditionallyProcess(pcClass.getOriginalClassLevel(1), "CAST", "5,4");
final PCClass pcClass2 = context.getReferenceContext().constructCDOMObject(PCClass.class, "Other Class");
context.unconditionallyProcess(pcClass2, "SPELLSTAT", "INT");
BuildUtilities.setFact(pcClass2, "SpellType", "Arcane");
context.unconditionallyProcess(pcClass2.getOriginalClassLevel(1), "CAST", "5,4");
context.getReferenceContext().buildDerivedObjects();
context.getReferenceContext().resolveReferences(null);
context.loadCampaignFacets();
final PlayerCharacter character = getCharacter();
setPCStat(character, cha, 12);
setPCStat(character, intel, 12);
character.incrementClassLevel(1, pcClass);
character.incrementClassLevel(2, pcClass2);
final PreParserFactory factory = PreParserFactory.getInstance();
final Prerequisite prereq = factory.parse("PRECLASS:1,SPELLCASTER.ARCANE=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 pcgen.core.PCClass in project pcgen by PCGen.
the class PreClassTest method testPreClassLevelMax.
/**
* Test the PRE CLASSLEVELMAX token
* @throws Exception
*/
public void testPreClassLevelMax() throws Exception {
final PreClassLevelMaxParser parser = new PreClassLevelMaxParser();
final Prerequisite prereq = parser.parse("CLASSLEVELMAX", "1,Monk=1", false, false);
final Prerequisite dualPrereq = parser.parse("CLASSLEVELMAX", "2,Monk=1,Fighter=1", false, false);
final Prerequisite singlePrereq = parser.parse("CLASSLEVELMAX", "1,Monk=1,Fighter=1", false, false);
final PlayerCharacter character = getCharacter();
assertTrue("Should pass with no levels", PrereqHandler.passes(prereq, character, null));
assertTrue("Should pass with no levels of either", PrereqHandler.passes(dualPrereq, character, null));
final PCClass pcClass = new PCClass();
pcClass.setName("Monk");
character.incrementClassLevel(1, pcClass);
assertTrue("Should pass with 1 level", PrereqHandler.passes(prereq, character, null));
assertTrue("Should pass with 1 level of one", PrereqHandler.passes(dualPrereq, character, null));
final PCClass ftrClass = new PCClass();
ftrClass.setName("Fighter");
character.incrementClassLevel(1, ftrClass);
assertTrue("Should pass with 1 level of each", PrereqHandler.passes(dualPrereq, character, null));
character.incrementClassLevel(1, pcClass);
assertFalse("Should not pass with 2 levels", PrereqHandler.passes(prereq, character, null));
assertFalse("Should not pass with 2 levels of one", PrereqHandler.passes(dualPrereq, character, null));
assertTrue("Should pass with 2 levels of one", PrereqHandler.passes(singlePrereq, character, null));
}
use of pcgen.core.PCClass in project pcgen by PCGen.
the class LocalSkillCostFacetTest method testRemoveUselessSource.
@Test
public void testRemoveUselessSource() {
Skill t1 = getObject();
assertFalse(getFacet().contains(id, class1, SkillCost.CLASS, t1));
addCost(id, class1, t1, SkillCost.CLASS);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
PCClass source2 = new PCClass();
removeCosts(id, source2);
assertTrue(getFacet().contains(id, class1, SkillCost.CLASS, t1));
}
Aggregations