Search in sources :

Example 61 with PreParserFactory

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

the class PreDeityTest method testPantheon.

/**
	 * Test the pantheon fucntioanlity of the PREDEITY tag. 
	 * @throws PersistenceLayerException 
	 */
public void testPantheon() throws PersistenceLayerException {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDEITY:1,PANTHEON.Celtic");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    character.setAlignment(ng);
    character.setDeity(deity);
    assertTrue("Character has Celtic deity selected", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDEITY:1,Zeus,PANTHEON.Celtic,Odin");
    assertTrue("Character has Celtic deity selected", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 62 with PreParserFactory

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

the class PreDeityTest method testBoolean.

/**
	 * Test that the boolean version (Y/N) works
	 * @throws Exception
	 */
public void testBoolean() throws Exception {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDEITY:1,Y");
    assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDEITY:1,N");
    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,Y");
    assertTrue("Character has deity selected", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 63 with PreParserFactory

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

the class PreDomainTest method testAny.

/**
	 * Test for any domain.
	 * 
	 * @throws Exception
	 */
public void testAny() 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,ANY");
    assertFalse("Character has no domains", PrereqHandler.passes(prereq, character, null));
    character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
    assertTrue("Character has one domain", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREDOMAIN:2,ANY");
    assertFalse("Character has only one domain", PrereqHandler.passes(prereq, character, null));
    character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Animal"));
    assertTrue("Character has two 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 64 with PreParserFactory

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

the class PreDRTest method testMultiAnd.

public void testMultiAnd() throws Exception {
    final PlayerCharacter character = getCharacter();
    character.setRace(race);
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDR:2,+1=10,+2=5");
    assertFalse("Character has no DR", PrereqHandler.passes(prereq, character, null));
    race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1);
    character.setRace(race);
    assertFalse("Character DR not 10", PrereqHandler.passes(prereq, character, null));
    DamageReduction drPlus2_5 = new DamageReduction(FormulaFactory.getFormulaFor(5), "+2");
    race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus2_5);
    //This weirdness is because we are altering the race after application (no-no at runtime)
    character.setRace(null);
    character.setRace(race);
    assertFalse("Character has DR 5/+2", PrereqHandler.passes(prereq, character, null));
    DamageReduction drPlus1_10 = new DamageReduction(FormulaFactory.getFormulaFor(10), "+1");
    race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1_10);
    //This weirdness is because we are altering the race after application (no-no at runtime)
    character.setRace(null);
    character.setRace(race);
    assertTrue("Character has DR 10/+1 and 5/+2", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) DamageReduction(pcgen.cdom.content.DamageReduction)

Example 65 with PreParserFactory

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

the class PreDRTest method testDR.

/**
	 * Test basic functionality
	 * @throws Exception
	 */
public void testDR() throws Exception {
    final PlayerCharacter character = getCharacter();
    character.setRace(race);
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREDR:1,+1=10");
    assertFalse("Character has no DR", PrereqHandler.passes(prereq, character, null));
    race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1);
    //This weirdness is because we are altering the race after application (no-no at runtime)
    character.setRace(null);
    character.setRace(race);
    assertFalse("Character DR not 10", PrereqHandler.passes(prereq, character, null));
    DamageReduction drPlus1_10 = new DamageReduction(FormulaFactory.getFormulaFor(10), "+1");
    race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1_10);
    //This weirdness is because we are altering the race after application (no-no at runtime)
    character.setRace(null);
    character.setRace(race);
    assertTrue("Character has DR 10/+1", PrereqHandler.passes(prereq, character, null));
}
Also used : PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) DamageReduction(pcgen.cdom.content.DamageReduction)

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