Search in sources :

Example 26 with PreParserFactory

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

the class PreDeityTest method testFormat.

/**
	 * Test different formats for the option
	 * @throws Exception
	 */
public void testFormat() throws Exception {
    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)

Example 27 with PreParserFactory

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

the class PreDomainTest method testMultiple.

/**
	 * Test with multiple options
	 * @throws Exception
	 */
public void testMultiple() throws Exception {
    final PlayerCharacter character = getCharacter();
    PCClass cl = new PCClass();
    character.setDefaultDomainSource(new ClassSource(cl, 1));
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDOMAIN:1,Good,Law");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    character.setAlignment(ng);
    character.setDeity(deity);
    assertFalse("Character's deity has Good domain", PrereqHandler.passes(prereq, character, null));
    character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
    assertTrue("Character has Good domain", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDOMAIN:2,Good,Law");
    assertFalse("Character doesn't have Law domain", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDOMAIN:2,Good,Animal");
    character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Animal"));
    assertTrue("Character's deity has Good and animal domains", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain) ClassSource(pcgen.cdom.helper.ClassSource)

Example 28 with PreParserFactory

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

the class PreCheckTest 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("PRECHECK:1,Fortitude=1");
    assertTrue("Character's Fort save should be 1", 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=3");
    assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PRECHECK:2,Fortitude=2,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) BonusObj(pcgen.core.bonus.BonusObj) LoadContext(pcgen.rules.context.LoadContext)

Example 29 with PreParserFactory

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

the class PreDeityDomainTest method testSingle.

/**
	 * Test for a single domain
	 * @throws Exception
	 */
public void testSingle() throws Exception {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDEITYDOMAIN:1,Good");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    character.setAlignment(ng);
    character.setDeity(deity);
    assertTrue("Character's deity has Good domain", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDEITYDOMAIN:1,Law");
    assertFalse("Character's deity doesn't have Law domain", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 30 with PreParserFactory

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

the class PreDomainTest method testDeity.

/**
	 * Test to make sure it is not looking at deity domains
	 * @throws Exception
	 */
public void testDeity() throws Exception {
    final PlayerCharacter character = getCharacter();
    PCClass cl = new PCClass();
    character.setDefaultDomainSource(new ClassSource(cl, 1));
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDOMAIN:1,Good");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    character.setAlignment(ng);
    character.setDeity(deity);
    assertFalse("Character's deity has Good domain", PrereqHandler.passes(prereq, character, null));
    character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
    assertTrue("Character has Good domain", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain) ClassSource(pcgen.cdom.helper.ClassSource)

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