Search in sources :

Example 86 with PreParserFactory

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

the class PreSizeTest method testEquipmentPreSize.

public void testEquipmentPreSize() throws Exception {
    final PlayerCharacter character = getCharacter();
    Globals.getContext().getReferenceContext().resolveReferences(null);
    is(eq1.sizeInt(), eq(3), "Item one is expected size");
    is(eq2.sizeInt(), eq(4), "Item two is expected size");
    is(eq3.sizeInt(), eq(5), "Item three is expected size");
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PRESIZEEQ:L");
    is(PrereqHandler.passes(prereq, eq1, character), eq(false), "Item one is not Large");
    is(PrereqHandler.passes(prereq, eq2, character), eq(false), "Item two is not Large");
    is(PrereqHandler.passes(prereq, eq3, character), eq(true), "Item three Large");
    prereq = factory.parse("PRESIZEGT:S");
    is(PrereqHandler.passes(prereq, eq1, character), eq(false), "Item one is not larger than Small");
    is(PrereqHandler.passes(prereq, eq2, character), eq(true), "Item two is larger than Small");
    is(PrereqHandler.passes(prereq, eq3, character), eq(true), "Item three larger than Small");
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 87 with PreParserFactory

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

the class PreSkillTest method testServesAsTypeMatch.

public void testServesAsTypeMatch() throws Exception {
    final PlayerCharacter character = getCharacter();
    final PreParserFactory factory = PreParserFactory.getInstance();
    Prerequisite prereq = factory.parse("PRESKILL:1,TYPE.INT=4");
    assertEquals(true, PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRESKILL:1,TYPE.STR=6");
    assertEquals(true, PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRESKILL:1,TYPE.ST%=6");
    assertEquals(true, PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRESKILL:1,TYPE.STR=7");
    assertEquals(false, PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRESKILL:1,TYPE.ST%=7");
    assertEquals(false, PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRESKILL:1,TYPE.CHA=1");
    assertEquals(false, PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRESKILL:1,TYPE.CH%=7");
    assertEquals(false, PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 88 with PreParserFactory

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

the class PrePCLevelTest method testPCLevel.

/**
	 * Make sure BONUS:PCLEVEL is not counted
	 * @throws Exception
	 */
public void testPCLevel() throws Exception {
    final PlayerCharacter character = getCharacter();
    LoadContext context = Globals.getContext();
    character.incrementClassLevel(2, myClass, true);
    myClass = character.getClassKeyed("MY_CLASS");
    character.setRace(race);
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREPCLEVEL:MIN=6");
    final BonusObj levelBonus = Bonus.newBonus(context, "PCLEVEL|MY_CLASS|2");
    myClass.addToListFor(ListKey.BONUS, levelBonus);
    character.calcActiveBonuses();
    assertFalse("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPCLEVEL:MAX=6");
    assertTrue("Character has more than 6 levels", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("!PREPCLEVEL:MAX=6");
    assertFalse("Character is less than 6 levels", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("!PREPCLEVEL:MIN=5");
    assertTrue("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPCLEVEL:MIN=4,MAX=6");
    assertFalse("Character does not have 4-6 levels", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPCLEVEL:MIN=6,MAX=8");
    assertFalse("Character does not have 6-8 levels", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("!PREPCLEVEL:MIN=6,MAX=8");
    assertTrue("Character is not 6-8 levels", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) BonusObj(pcgen.core.bonus.BonusObj) LoadContext(pcgen.rules.context.LoadContext)

Example 89 with PreParserFactory

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

the class PreShieldProfTest method testMultiple.

/**
	 * Tests to see if a character has a certain number of shieldprofs 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("PREPROFWITHSHIELD:1,Heavy Wooden Shield,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", "SHIELDPROF|Heavy Wooden Shield");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Full Plate");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    assertTrue("Character has one of Heavy Wooden Shield or Full Plate proficiency", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:2,Heavy Wooden Shield,Full Plate");
    assertTrue("Character has both Heavy Wooden Shield and Full Plate proficiency", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:3,Heavy Wooden Shield,Full Plate,Light Wooden Shield");
    assertFalse("Character has both Heavy Wooden Shield and Full Plate proficiency but not Light Wooden Shield", PrereqHandler.passes(prereq, character, null));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 90 with PreParserFactory

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

the class PreGenderTest method testGender.

/**
	 * Test the PREGENDER code
	 * @throws Exception
	 */
public void testGender() throws Exception {
    final PlayerCharacter character = getCharacter();
    character.setGender(Gender.Male);
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREGENDER:M");
    assertTrue("Character is Male", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREGENDER:m");
    assertFalse("Case is significant", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREGENDER:Moose");
    assertFalse("Requires a full match", 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