Search in sources :

Example 36 with PreParserFactory

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));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 37 with PreParserFactory

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));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 38 with PreParserFactory

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));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 39 with PreParserFactory

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));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 40 with PreParserFactory

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));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Aggregations

PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)107 PlayerCharacter (pcgen.core.PlayerCharacter)89 LoadContext (pcgen.rules.context.LoadContext)16 BonusObj (pcgen.core.bonus.BonusObj)13 Prerequisite (pcgen.core.prereq.Prerequisite)12 Ability (pcgen.core.Ability)11 PCClass (pcgen.core.PCClass)11 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 StringTokenizer (java.util.StringTokenizer)5 Domain (pcgen.core.Domain)5 PCTemplate (pcgen.core.PCTemplate)5 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)5 URI (java.net.URI)4 Equipment (pcgen.core.Equipment)4 PersistenceManager (pcgen.persistence.PersistenceManager)4 DamageReduction (pcgen.cdom.content.DamageReduction)3 ClassSource (pcgen.cdom.helper.ClassSource)3 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)3 QualifiedObject (pcgen.core.QualifiedObject)3