use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreAlignTest method testMulti.
public void testMulti() throws Exception {
final PlayerCharacter character = getCharacter();
character.setAlignment(ng);
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("PREALIGN:LE,NG,NE");
assertTrue("LE, NG, or NE should match character's alignment of NG", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREALIGN:LE,NE,CE");
assertFalse("LE, NE, or CE should not match character's alignment of NG", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreAlignTest method testNegative.
/**
* Test that negative (!) alignment checks work correctly in Align tests.
* @throws Exception
*/
public void testNegative() throws Exception {
final PlayerCharacter character = getCharacter();
character.setAlignment(ng);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("!PREALIGN:TN");
assertTrue("Not TN should match character's alignment of NG", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREALIGN:NG");
assertFalse("Not TN should not match character's alignment of NG", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreArmorProfTest method testInverse.
/**
* Test with negation.
*
* @throws Exception the exception
*/
public void testInverse() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("!PREPROFWITHARMOR:1,Breastplate");
assertTrue("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "ARMORPROF|Chainmail");
Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "ARMORPROF|Breastplate");
assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
assertFalse("Character has the Breastplate proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPROFWITHARMOR:1,Leather");
assertTrue("Character does not have the Leather proficiency", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPROFWITHARMOR:1,Chainmail");
assertFalse("Character has the Chainmail proficiency.", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PrereqHandlerTest method testPasses.
/**
* Test the passes method. Currently this concentrates on making sure
* the invert result is working.
* @throws PersistenceLayerException
*/
public void testPasses() throws PersistenceLayerException {
final PreParserFactory factory = PreParserFactory.getInstance();
final Prerequisite prereqNeg = factory.parse("!PREALIGN:LG,LN,LE");
final Prerequisite prereq = factory.parse("PREALIGN:NG,TN,NE,CG,CN,CE");
final PlayerCharacter pc = getCharacter();
final Race human = new Race();
human.setName("Human");
pc.setRace(human);
pc.setAlignment(le);
assertEquals("Non-negate returns false", false, PrereqHandler.passes(prereq, pc, null));
assertEquals("Negate returns false", false, PrereqHandler.passes(prereqNeg, pc, null));
pc.setAlignment(tn);
assertEquals("Non-negate returns true", true, PrereqHandler.passes(prereq, pc, null));
assertEquals("Negate returns true", true, PrereqHandler.passes(prereqNeg, pc, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreCharactertypeTest method testCharactertype.
/**
* Test to make sure it is not looking at deity domains
* @throws Exception
*/
public void testCharactertype() throws Exception {
final PlayerCharacter character = getCharacter();
character.setCharacterType("PC");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRECHARACTERTYPE:1,PC");
assertTrue("Character has character type 'PC'", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHARACTERTYPE:1,NPC");
assertFalse("Character doesn't have character type 'NPC'", PrereqHandler.passes(prereq, character, null));
}
Aggregations