use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PrereqHandlerTest method testFeatPasses.
/**
* Tests PREFEAT
* @throws PersistenceLayerException
*/
public void testFeatPasses() throws PersistenceLayerException {
final PreParserFactory factory = PreParserFactory.getInstance();
final Prerequisite prereq = factory.parse("!PREFEAT:1,Uncanny Dodge");
final PlayerCharacter pc = getCharacter();
final Race human = new Race();
human.setName("Human");
pc.setRace(human);
assertTrue("No feat should return true", PrereqHandler.passes(prereq, pc, null));
final Ability ud = new Ability();
ud.setName("Uncanny Dodge");
ud.setCDOMCategory(AbilityCategory.FEAT);
ud.put(StringKey.KEY_NAME, "Uncanny Dodge");
addAbility(AbilityCategory.FEAT, ud);
assertFalse("Feat should return false", PrereqHandler.passes(prereq, pc, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreAlignTest method testDeity.
/**
* Tests that this only passes if the character's alignment matches his
* diety's alignment.
* @throws Exception
*/
public void testDeity() throws Exception {
final PlayerCharacter character = getCharacter();
character.setAlignment(ng);
character.setDeity(deity);
assertEquals("Deity should have been set for character.", deity, character.getDeity());
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("PREALIGN:Deity");
assertTrue("Number 3 should match deity's alignment of NG", PrereqHandler.passes(prereq, character, null));
character.setAlignment(cg);
assertFalse("Number 6 should not match deity's alignment of NG", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreWeaponProfTest method testOneOption.
/**
* Test with a simple weapon proficiency
* @throws Exception
*/
public void testOneOption() throws Exception {
final PlayerCharacter character = getCharacter();
PCTemplate pct = new PCTemplate();
LoadContext context = Globals.getContext();
context.unconditionallyProcess(pct, "AUTO", "WEAPONPROF|Longsword|Dagger");
assertTrue(context.getReferenceContext().resolveReferences(null));
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREWEAPONPROF:1,Longsword");
assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
character.addTemplate(pct);
assertTrue("Character has the Longsword proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREWEAPONPROF:1,Longbow");
assertFalse("Character does not have the Longbow proficiency", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREWEAPONPROF:1,Dagger");
assertTrue("Character has the Dagger proficiency.", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSpellSubSchoolTest method testTwoClassSUBSCHOOL.
public void testTwoClassSUBSCHOOL() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("PRESPELLSCHOOLSUB:3,Fire=2,Useful=2");
assertFalse(PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, wiz);
boolean passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
character.incrementClassLevel(1, wiz);
passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSpellTypeTest method testNotTwoClassType.
public void testNotTwoClassType() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("!PRESPELLTYPE:3,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);
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);
}
Aggregations