Search in sources :

Example 41 with PreParserFactory

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

Example 42 with PreParserFactory

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

Example 43 with PreParserFactory

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

Example 44 with PreParserFactory

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

Example 45 with PreParserFactory

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);
}
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