Search in sources :

Example 56 with PreParserFactory

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

the class PreCheckBaseTest method testBonus.

public void testBonus() throws Exception {
    final PlayerCharacter character = getCharacter();
    LoadContext context = Globals.getContext();
    final BonusObj fortBonus = Bonus.newBonus(context, "SAVE|Fortitude|1");
    myClass.getOriginalClassLevel(1).addToListFor(ListKey.BONUS, fortBonus);
    character.incrementClassLevel(1, myClass, true);
    character.calcActiveBonuses();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PRECHECKBASE:1,Fortitude=1");
    assertFalse("Character's base Fort save should be 0", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECKBASE:1,Will=2");
    assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECKBASE:1,Fortitude=1,Will=3");
    assertFalse("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECKBASE:2,Fortitude=1,Will=2");
    assertFalse("Character's base Fort save not 1", 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 57 with PreParserFactory

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

the class PreCheckBaseTest method testBase.

/**
	 * Test that Base Checks work
	 * @throws Exception
	 */
public void testBase() throws Exception {
    final PlayerCharacter character = getCharacter();
    character.incrementClassLevel(1, myClass, true);
    character.calcActiveBonuses();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PRECHECKBASE:1,Fortitude=0");
    assertTrue("Character's Fort save should be 0", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECKBASE:1,Will=2");
    assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECKBASE:1,Fortitude=1,Will=2");
    assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECKBASE:2,Fortitude=1,Will=2");
    assertFalse("Character's Fort save not 1", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 58 with PreParserFactory

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

the class PreCheckTest method testBase.

/**
	 * Test that Base Checks work
	 * @throws Exception
	 */
public void testBase() throws Exception {
    final PlayerCharacter character = getCharacter();
    character.incrementClassLevel(1, myClass, true);
    character.calcActiveBonuses();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PRECHECK:1,Fortitude=0");
    assertTrue("Character's Fort save should be 0", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECK:1,Will=2");
    assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECK:1,Fortitude=1,Will=2");
    assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECK:2,Fortitude=1,Will=2");
    assertFalse("Character's Fort save not 1", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 59 with PreParserFactory

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

the class PreDeityTest method testName.

/**
	 * Test naming specific deities works as expected
	 * @throws Exception
	 */
public void testName() throws Exception {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDEITY:1,Test Deity");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    character.setAlignment(ng);
    character.setDeity(deity);
    assertTrue("Character has Test Deity selected", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDEITY:1,Test Deity,Zeus,Odin");
    assertTrue("Character has Test Deity selected", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 60 with PreParserFactory

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

the class PreDeityTest method testNewFormat.

/**
	 * Test that the new standardised format works correctly.
	 * @throws PersistenceLayerException
	 */
public void testNewFormat() throws PersistenceLayerException {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDEITY:1,YES");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDEITY:1,NO");
    assertTrue("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    character.setAlignment(ng);
    character.setDeity(deity);
    assertFalse("Character has deity selected", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDEITY:1,YES");
    assertTrue("Character has deity selected", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDEITY:1,yes");
    assertTrue("Character has deity selected", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDEITY:1,Yesmeth");
    assertFalse("Character does not have Yesmeth as deity", 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