use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreAlignTest method testAbbrev.
/**
* Test that alignment abbreviation values work correctly in Align tests.
* @throws Exception
*/
public void testAbbrev() throws Exception {
final PlayerCharacter character = getCharacter();
character.setAlignment(ng);
Prerequisite prereq = new Prerequisite();
prereq.setKind("align");
prereq.setKey("NG");
prereq.setOperator(PrerequisiteOperator.EQ);
assertTrue("Abbrev NG should match character's alignment of NG", PrereqHandler.passes(prereq, character, null));
prereq = new Prerequisite();
prereq.setKind("align");
prereq.setKey("LG");
prereq.setOperator(PrerequisiteOperator.EQ);
assertFalse("Abbrev LG should not match character's alignment of NG", PrereqHandler.passes(prereq, character, null));
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREALIGN:NG");
assertTrue("Abbrev NG should match character's alignment of NG", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREALIGN:LG");
assertFalse("Abbrev LG 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 testType.
/**
* Test a preweaponprof that checks for a number of profs of a certain type.
*
* @throws Exception the exception
*/
public void testType() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPROFWITHARMOR:1,TYPE.Medium");
assertFalse("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|ARMORTYPE=Medium");
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
assertTrue("Character has Medium Armor Proficiency", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreArmorProfTest method testOneOption.
/**
* Test with a simple armor proficiency.
*
* @throws Exception the exception
*/
public void testOneOption() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPROFWITHARMOR:1,Chainmail");
assertFalse("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|Full Plate");
assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
assertTrue("Character has the Chainmail proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHARMOR:1,Leather");
assertFalse("Character does not have the Leather proficiency", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHARMOR:1,Full Plate");
assertTrue("Character has the Full Plate proficiency.", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreArmorProfTest method testArmorProfAddedWithAutoArmorProf.
/**
* Test the prearmorprof with armorprofs added by a AUTO:ARMORPROF tag
* This is probably more an integration test than a unit test
*
* @throws Exception the exception
*/
public void testArmorProfAddedWithAutoArmorProf() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPROFWITHARMOR:1,Breastplate");
assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
final Ability martialProf = TestHelper.makeAbility("Armor Proficiency (Single)", AbilityCategory.FEAT, "General");
Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "ARMORPROF|ARMORTYPE=Medium");
assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
assertTrue("Character has the Breastplate proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHARMOR:1,Chainmail");
assertTrue("Character has the Chainmail proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHARMOR:1,Leather");
assertFalse("Character does not have the Leather proficiency.", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHARMOR:1,TYPE.Medium");
assertTrue("Character has martial weaponprofs.", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreArmorProfTest method testMultiple.
/**
* Tests to see if a character has a certain number of weaponprofs from a list.
*
* @throws Exception the exception
*/
public void testMultiple() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPROFWITHARMOR:1,Chainmail,Full Plate");
assertFalse("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|Full Plate");
assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
assertTrue("Character has one of Chainmail or Full Plate proficiency", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHARMOR:2,Chainmail,Full Plate");
assertTrue("Character has both Chainmail and Full Plate proficiency", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHARMOR:3,Chainmail,Full Plate,Leather");
assertFalse("Character has both Chainmail and Full Plate proficiency but not Leather", PrereqHandler.passes(prereq, character, null));
}
Aggregations