use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSpellSchoolTest method testNotTwoClassSchool.
public void testNotTwoClassSchool() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("!PRESPELLSCHOOL:3,Fire=2,Useful=2");
assertTrue(PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, wiz);
boolean passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, wiz);
passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreWeaponProfTest method testType.
/**
* Test a preweaponprof that checks for a number of profs of a certain type
* @throws Exception
*/
public void testType() throws Exception {
final PlayerCharacter character = getCharacter();
PCTemplate pctls = new PCTemplate();
PCTemplate pctlb = new PCTemplate();
LoadContext context = Globals.getContext();
context.unconditionallyProcess(pctls, "AUTO", "WEAPONPROF|Longsword");
context.unconditionallyProcess(pctlb, "AUTO", "WEAPONPROF|Longbow");
assertTrue(context.getReferenceContext().resolveReferences(null));
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREWEAPONPROF:1,TYPE.Martial");
assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
character.addTemplate(pctls);
assertTrue("Character has one Martial Weapon Proficiency", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREWEAPONPROF:2,TYPE.Martial");
assertFalse("Character only has one proficiency", PrereqHandler.passes(prereq, character, null));
character.addTemplate(pctlb);
assertTrue("Character has two Martial Weapon Proficiencies", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreWeaponProfTest method testWeaponProfAddedWithAutoWeaponProf.
/**
* Test the preweaponprof with weaponprofs added by a AUTO:WEAPONPROF tag
* This is probably more an integration test than a unit test
* This test was written to help find the source of bug 1699779
* @throws Exception
*/
public void testWeaponProfAddedWithAutoWeaponProf() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREWEAPONPROF:1,Longsword");
assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
final Ability martialProf = TestHelper.makeAbility("Weapon Proficiency (Martial)", AbilityCategory.FEAT, "General");
Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "WEAPONPROF|TYPE.Martial");
assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
assertTrue("Character has the Longsword proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREWEAPONPROF:1,Longbow");
assertTrue("Character has the Longbow proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREWEAPONPROF:1,Dagger");
assertFalse("Character does not have the Dagger proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREWEAPONPROF:1,TYPE.Martial");
assertTrue("Character has martial weaponprofs.", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSpellSubSchoolTest method testNotTwoClassSUBSCHOOL.
public void testNotTwoClassSUBSCHOOL() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("!PRESPELLSCHOOLSUB:3,Fire=2,Useful=2");
assertTrue(PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, wiz);
boolean passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, wiz);
passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSpellTypeTest method testNotTwoType.
public void testNotTwoType() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("!PRESPELLTYPE:2,Arcane=2,Divine=2");
assertTrue(PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, wiz);
boolean passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, wiz);
passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
}
Aggregations