Search in sources :

Example 96 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class PreSpellSchoolTest method testNotTwoClassSchool.

public void testNotTwoClassSchool() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("!PRESPELLSCHOOL:3,Fire=2,Useful=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)

Example 97 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class PreWeaponProfTest method testType.

/**
	 * Test a preweaponprof that checks for a number of profs of a certain type
	 * @throws Exception
	 */
public void testType() throws Exception {
    final PlayerCharacter character = getCharacter();
    PCTemplate pctls = new PCTemplate();
    PCTemplate pctlb = new PCTemplate();
    LoadContext context = Globals.getContext();
    context.unconditionallyProcess(pctls, "AUTO", "WEAPONPROF|Longsword");
    context.unconditionallyProcess(pctlb, "AUTO", "WEAPONPROF|Longbow");
    assertTrue(context.getReferenceContext().resolveReferences(null));
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREWEAPONPROF:1,TYPE.Martial");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    character.addTemplate(pctls);
    assertTrue("Character has one Martial Weapon Proficiency", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREWEAPONPROF:2,TYPE.Martial");
    assertFalse("Character only has one proficiency", PrereqHandler.passes(prereq, character, null));
    character.addTemplate(pctlb);
    assertTrue("Character has two Martial Weapon Proficiencies", 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 98 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class PreWeaponProfTest method testWeaponProfAddedWithAutoWeaponProf.

/**
	 * Test the preweaponprof with weaponprofs added by a AUTO:WEAPONPROF tag
	 * This is probably more an integration test than a unit test
	 * This test was written to help find the source of bug 1699779
	 * @throws Exception
	 */
public void testWeaponProfAddedWithAutoWeaponProf() throws Exception {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREWEAPONPROF:1,Longsword");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    final Ability martialProf = TestHelper.makeAbility("Weapon Proficiency (Martial)", AbilityCategory.FEAT, "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "WEAPONPROF|TYPE.Martial");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    assertTrue("Character has the Longsword proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREWEAPONPROF:1,Longbow");
    assertTrue("Character has the Longbow proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREWEAPONPROF:1,Dagger");
    assertFalse("Character does not have the Dagger proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREWEAPONPROF:1,TYPE.Martial");
    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 99 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class PreSpellSubSchoolTest method testNotTwoClassSUBSCHOOL.

public void testNotTwoClassSUBSCHOOL() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("!PRESPELLSCHOOLSUB:3,Fire=2,Useful=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)

Example 100 with PreParserFactory

use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.

the class PreSpellTypeTest method testNotTwoType.

public void testNotTwoType() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("!PRESPELLTYPE:2,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);
    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