Search in sources :

Example 51 with PreParserFactory

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

Example 52 with PreParserFactory

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

Example 53 with PreParserFactory

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

Example 54 with PreParserFactory

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

Example 55 with PreParserFactory

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));
}
Also used : 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